javascript - phone_mobile validation prestashop -


i trying validation in prestashop in phone_mobile field @ checkout. validation trying detect first 2 numbers user types in field. so, if it's not specific numbers (04) if trying continue want show error when click continue order. how can that? isphonenumber function take place? can edit it?

can that:

$(document).ready(function(){     $('input#phone_mobile').change(function(){          if($(this).val()!='04'){         $(this).closest('div').removeclass('form-ok').addclass('form-error');         }          }); }); 

i think work error in end if user click continue , no errors @ all.

thanks!

$(document).ready(function(){     $('input#phone_mobile').on("input", function(){         if($(this).val().substring(0,1)!='04') {            $(this).closest('div').removeclass('form-ok').addclass('form-error');         }     }); }); 

you can use substring requirement done.. http://www.w3schools.com/jsref/jsref_substring.asp here tutorial.


Comments