javascript - Bootstrap enable button on input -
i having issues getting done correctly. want "sendit" button enable (remove disable) there characters in box. i've tried multiple things can not work.
part of html:
<input type="password" id="inputpassword" class="form-control" placeholder="password" required> <input id="sendit" class="btn btn-lg btn-primary btn-block disabled" type="submit" value="generate codes"></input>
js file
$(document).ready(function() { var pass_error = 1; // check name field if (inputpassword === '') { pass_error = 1; } else { pass_error = 0; } enablebutton(); }); // verzendknop pas activeren nadat alles ingevuld en gecontroleerd function enablebutton() { if (pass_error!== 0) { $('#btn btn-lg btn-primary btn-block').attr('disabled', 'disabled'); } else { $('#btn btn-lg btn-primary btn-block').removeattr('disabled'); } }; });
your code checks field once upon dom ready.
you need tie check keyup event on field:
$('my-field').keyup(function() { if($(this).val() === '') { pass_error = 1; } else { pass_error = 0; enablebutton(); });
Comments
Post a Comment