Posted By

ryarwood on 06/25/11


Tagged


Versions (?)

Ghetto Javascript Custom Error Checking


 / Published in: JavaScript
 

URL: http://www.pcrf-kids.org/summergala

  1. function donationCheck() {
  2. errors = "";
  3. // the nasty error string
  4. if (document.bottomForm.donationFinal.value == "None") {
  5. errors+= "Donation Amount\n";
  6. }
  7. if (document.bottomForm.donationFirstName.value == "") {
  8. errors+= "Fist Name\n";
  9. }
  10. if (document.bottomForm.donationLastName.value == "") {
  11. errors+= "Last Name\n";
  12. }
  13. if (document.bottomForm.donationPhone.value == "") {
  14. errors+= "Phone Number\n";
  15. }
  16. if (document.bottomForm.donationEmail.value == "") {
  17. errors+= "Email\n";
  18. }
  19.  
  20. if(document.bottomForm.donationFinal.value == "Other" && document.bottomForm.otherDonation.value == "OTHER") {
  21. errors+= "Other Donation Amount\n";
  22. }
  23.  
  24. if (errors == "") {
  25. submitDonation();
  26. } else {
  27. alert("Please fill in the following fields:\n" + errors);
  28. }
  29. }

Report this snippet  

You need to login to post a comment.