I'm trying to use ValidationEngine (https://github.com/posabsolute/jQuery-Validation-Engine) I need to validate one field (for email) before the whole form will be validated:
$(document).on("click", "#EmailButton", function(){
var valid=$("#Email").validationEngine('validate');
alert(valid);
})
$("#<?=$formName?>").validationEngine({
promptPosition:'topLeft',
scroll: false,
binded: false,
onValidationComplete: function(form, status){
if(status==true){
$.ajax({
type: "POST", ... ... ... }
}
So, when I click on #EmailButton
the #Email
field should be validated, not whole form.
But when the #EmailButton
is clicked, the ajax script from $("#<?=$formName?>").validationEngine({
is run!
I need this feature because I want to make some changes in the form after the #Email
field is filled (if email is in Database or not).
How can I validate the #Email
field before to run the $("#<?=$formName?>").validationEngine({})
script ?
Thanks.
Try this:
In HTML:
<form id="emailForm">
Email:<input type="email" id="txtEmail" class="validate[required,custom[email],maxSize[30]]"/>
<input type="button" value="Email Verify" onclick="emailCheck()"/>
</form>
In Jquery:
function emailCheck()
{
if($("#emailForm").validationEngine('validate') == true)
{
alert('valid');
}
else
{
alert('not valid');
}
}