loboo19 loboo19 - 2 months ago 5
jQuery Question

jQuery Phone Validation dosen't work after refresh page

I have script

$(document).ready(function(){
var phoneInput = $('.custom-options').val(372);
var inputCart = $('.wc-variation-selection-needed');
inputCart.attr('disabled','disabled');

phoneInput.keyup(function() {
if (!phoneInput.val().match(/^372\d{8}$/)) {
inputCart.attr('disabled','disabled');
} else {
inputCart.removeAttr('disabled');
}
});
});


this work, but only once, if i click the button and send form, inputCart will be still enable.

Answer

That would be a good practice to use prop("disabled", true) and prop("disabled", false) to enable/disable the element

Comments