Posted By

ryarwood on 06/09/11


Tagged

form javascript jquery p11


Versions (?)

Jquery Form Submission & Form Check


 / Published in: jQuery
 

  1. function submissionCheck() {
  2. errors = "";
  3. // the nasty error string
  4. if (document.newsForm.firstName.value == "") {
  5. errors+= "First Name\n";
  6. }
  7. if (document.newsForm.lastName.value == "") {
  8. errors+= "Fist Name\n";
  9. }
  10. if (document.newsForm.email.value == "") {
  11. errors+= "Last Name\n";
  12. }
  13. if (document.newsForm.title.value == "") {
  14. errors+= "Title\n";
  15. }
  16. if (document.newsForm.occupation.value == "") {
  17. errors+= "Occupation\n";
  18. }
  19. if (errors == "") {
  20. $.post('http://www.buildingindustryshow.com/dev/includes/process.php', $("#newsForm").serialize(), function(data) {
  21. //$('#results').html(data);
  22. alert("success");
  23. });
  24. } else {
  25. alert("Please fill in the following fields:\n" + errors);
  26. }
  27. }

Report this snippet  

You need to login to post a comment.