1

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.

loboo19
  • 13
  • 3
  • How do you "send form" and subsequently regenerate the form? Add the keyup code there as well or use dynamic binding: http://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements – freedomn-m Sep 12 '16 at 13:37

1 Answers1

0

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

Zay Lau
  • 1,856
  • 1
  • 10
  • 17