jquery - Foundation email validation ajax -
i new zurb foundation concept , inherited work do. in form see following
<div class="row"> <div class="small-12 column name-field"> <label class="show-for-medium-up">e-mail-adresse:*</label> <input type="text" id="emailaddress" name="emailaddress" value="${requestparameters.emailaddress!}" placeholder="" required pattern="email" /> <small class="error"><i class="fi-alert"></i>please provide email address.</small> </div> </div> <div class="row"> <div class="small-12 column name-field"> <label class="show-for-medium-up">repeat email address*</label> <input type="text" name="emailaddressconfirmation" value="${requestparameters.emailaddressconfirmation!}" placeholder="" pattern="email" data-equalto="emailaddress"/> <small class="error"><i class="fi-alert"></i>the email address don't match</small> </div> </div>
i understand how works.
but have add additional functionality when 2 email addresses match email address must checked existence in database of app , if should show next row - label, field , message (alert), following code:
<div class="row"> <div class="small-12 column name-field"> <label>id code:</label> <input type="text" name="idcode" value="${requestparameters.idcode!}" placeholder="" required/> <small class="error"><i class="fi-alert"></i>this email address exists. please provide id code.</small> </div> </div>
the question is: how make happen?
regards, , in advance
$(document).foundation({ abide : { validators: { notinuse: function(el, required, parent) { return mydbvalidation(el.val); // returns true or false. el element. } } } });
then use standard one:
<input type="email" data-abide-validator="notinuse">
i didn't find way perform asynchronous validation of field, can this:
in function mydbvalidation(el.val);
check local map(cache) of invalid emails , if validated email isn't there, perform ajax query db email , return true
. in ajax callback, if email invalid, add map , trigger validation $("#myelement").trigger("change");
time email address in invalid email cache , validation fail.
Comments
Post a Comment