0

The script work great but the button stay disabled if a value is enter with javascript.im forced to write on the field myself , there is a way to check , refresh if a value is here ?

 $(document).ready(function () {
     validate();
     $('#stylish, #name_1, #specialImg1, #specialImg2,#specialImg2').change(validate);
 });

 function validate() {
     if ($('#stylish').val().length > 0 &&
         $('#name_1').val().length > 0 &&
         $('#specialImg1').val().length > 0 &&
         $('#specialImg2').val().length > 0 &&
         $('#specialImg3').val().length > 0) {
         $(".elbutton").prop("disabled", false);
     } else {
         $(".elbutton").prop("disabled", true);
     }
 }
Andreas
  • 21,535
  • 7
  • 47
  • 56
Mr Stark
  • 3
  • 1
  • 6

2 Answers2

1

The onchange event is only triggered on changes made by the user.

If you change the values using javascript you must manually trigger the event. Example:

$('#stylish').val('some value').change();

More information: .val() doesn't trigger .change() in jquery

Community
  • 1
  • 1
Alexandru Severin
  • 6,021
  • 11
  • 48
  • 71
0

You better provide the fiddle so that we have more idea what is wrong with your script. As far as I know, you will need to call the change event or the validation function after you make changes from the javascript. The change event requires an actual browser event initiated by the user instead of via javascript code.

Mg Thar
  • 1,084
  • 8
  • 24