Make input inactive
I have the following input:
<input type="submit" name="next" value="Next"> How can I make this element without clicking through jQuery? (i.e. it can only be clicked after , certain verification criteria are met)?
The following question is below: Make sending clickable after validation
2 Demos Demo 1 click here: or Demo 2 click here:
so all you need to do is verify that the validation is done correctly.
i.e. if (notValid) in the code below and this will disable the button. or better to start with the next button disabled.
To enable, you can set the property as false, I'm sure you will get a good idea, otherwise provide more code; I am happy to help you. B -)
Hope this helps!
$("#submit").prop('disabled', true); OR
$("input[type='submit']").prop('disabled', true); $('input[name="next"]').prop('disabled', true); you can use:
$("input[type=submit][name='next']").attr("disabled", "disabled"); // unclickable $("input[type=submit][name='next']").removeAttr("disabled"); // clickable Disabling the input element does not always prevent click events or their further distribution in browsers.
Despite this, it would be advisable to simply return false if the check fails, so the action (i.e. submitting the form) fails. This will prevent the form from being submitted, and since the click handler will still be executed, you can provide the user with information about why the message failed:
$("#submit").click(function(){ var isValid = true; /*perform validation checks, changing isValid value to false when needed*/ return isValid; //will return false if validation fails etc. });