I am using the validate plugin with a form that has one select element
and no other elements.  I am using the required and remote rules to
validate this element.  When I click submit the first time, it
performs the remote validation, but doesn't submit the form. A second
click on the submit button then submits the form.  I'm trying to
figure out why it's not submitting on the first click?

The code below shows both client and server side action.  I am seeing
on the first click that remote.php returns 'true' via Firebug, but for
some reason doesn't submit the form, it only performs the remote
validation and then stops... Any advice is appreciated

client side:
$(document).ready(function() {
var validator = $('#my_form').validate({
 rules: {
  field: {
         required: true,
        remote: "remote.php"
   },
 },
messages: {
 field: {
  required: "Please specify a value",
  remote: jQuery.format("Please specify another value.")
 },
},
});
});

<form action="" method="post" name="my_form" id="my_form">
<select name="field">
<option value=""> --------- </option>
<option value="1">some_value</option>
<option value="2">some_other_value</option>
</select>
<input type="submit" name="submit" value="Submit">
</form>

Server Side (remote.php)
<?php
$valid = 'true';

// do a database lookup or similar action...
if($_REQUEST['field'] != $database_lookup_result)
 $valid = 'false';

echo $valid;
?>

Reply via email to