I have a multistep form, where I use Parsley JS Validator for the entire form, this works lige it should, but in a certain field called "initials" I need to validate using an AJAX return to validate if the initials are available or not. The field validates fine on focusout on the pattern and length, but its like I am unable to trigger the AJAX and does not get any errors or feedback in Chrome Developer Console, so I am having a little difficult debugging it .. can anyone come with a clue to what is wrong here?
The input "initials" field:
<input class="maxLength form-control" type="text" name="initials" id="initials" data-parsley-pattern="^[a-zA-Z]+$" data-parsley-errors-container="#initials-errors" data-parsley-trigger="focusout" data-parsley-initials data-parsley-initials-message="Initials allready taken" maxlength="3" minlength="3" Required>
Overall Parsley Form validation:
$('.form-navigation .next').click(function() {
$('.demo-form').parsley().whenValidate({
group: 'block-' + curIndex()
}).done(function() {
navigateTo(curIndex() + 1);
});
});
Initials field Parsley validation:
$('#initials').parsley();
window.Parsley.addValidator('checkinitials', {
validateString: function(value)
{
return $.ajax({
url:'check_initials_availability.asp',
method:"POST",
data:{initials:value},
dataType:"json",
success:function(data)
{
return true;
}
});
}