I'm using this jQuery form validator but I cannot understand how to make one simple thing here: if form is not valid disable the submit button, otherwise enable submit button.
A little bit of code:
<script type="text/javascript">
$(document).ready(function() {
$("#registration_form").validationEngine({
//
});
});
</script>
<?php
echo "<form id=\"registration_form\">";
echo "<label for=\"name\">Name</label>";
echo "<input class=\"validate[required,custom[onlyLetter],length[3,100]]\" id=\"name\"><br />";
echo "<button type=\"submit\" id=\"submit_button\">GO</button>";
echo "</form>";
?>
This is the script
<script type="text/javascript">
$(document).ready(function() {
$("#registration_form").validationEngine(
{
inlineValidation: true
});
$('.change').change(function() {
validate();
});
validate();
});
function validate(){
var res = $.validationEngine.loadValidation("#name");
if (!res)
$("#submit_button").attr('disabled','');
else
$("#submit_button").attr("disabled","disabled");
}
</script>
in the body
<input class="validate[required,custom[onlyLetter],length[3,100]] change"
id="name" value=""><br />
try and feedback me