Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery form validation not working
    primarykey
    data
    text
    <p>I'm struggling with my form validation here:</p> <pre><code>// JavaScript Document $(document).ready( function() { $("#submit").click(function(){ // set initial error value to false var hasError = false; // set var for each form field var order_ref = $("#order_ref").val(); var order_name = $("#order_name").val(); var order_telephone = $("#order_telephone").val(); var order_email = $("#order_email").val(); var order_message = $("#order_message").val(); var order_size = $("#sendEmail input.radio:checked").val(); // validate each of them if(order_ref == '') { $("#order_ref").addClass('haserror'); hasError = true; } if(order_name == '') { $("#order_name").addClass('haserror'); hasError = true; } if(order_telephone == '') { $("#order_telephone").addClass('haserror'); hasError = true; } if(order_email == '') { $("#order_email").val().addClass('haserror'); hasError = true; } //if(order_message == '') { $("#order_message").val().addClass('haserror'); hasError = true; } if(order_size == '') { $("#order_size").val().addClass('haserror'); hasError = true; } // if there are errors if(hasError == true) { alert('whoa!'); return false; }; // if there's no errors, proceed if(hasError == false) { $.post("/photo/theme/foodphoto/includes/mail_send.php", { // pass each of the form values to the PHP file for processing order_ref: order_ref, order_name: order_name, order_telephone: order_telephone, order_email: order_email, order_message: order_message, order_size: order_size }, function(data){ // no errors? great now do what you want to show the user his message is sent $('#sendEmail, .faded').slideUp(500); $('.thanks').delay(500).fadeIn(500); } ); }; return false; }); }); </code></pre> <p>Can you spot what I'm doing wrong?</p> <p>Thank you! :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload