I have this form
<form id="form" method="POST" onsubmit="return validate()"> <input type="text" id="name" name="name"> <input type="submit" value="next"> </form>
and this validation
if ($("#name").val() == "") { return false; } return true;
what I am trying to do, is to disable the submit button, I tried to use submit function for the form but its not triggered, the problem is I don't have access to html or js files, only one custom.js file I can add or override other functions.
anyone can help me ?
Thanks
so if you have $("#name")
probably you have the jquery library.
in this case you can try remove onsubmit
html property directly and use this event from jquery. $("#form").submit(...)
and there you can use your validation function with return boolean value
You can override the validate function (but it is a bit dirty):
function validate() { console.log('default validator'); return false; } var defaultValidator = validate; window.validate = function () { defaultValidator(); console.log('custom validator'); return false; };
<form id="form" method="POST" onsubmit="return validate()"> <input type="text" id="name" name="name"> <input type="submit" value="next"> </form>
Try this in your validate function.
$('#form>submit').prop('disabled', true);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.