Reputation: 435
I have the below form:
<form>
<input type="name" required/>
<input type="button" value="Send"/>
</form>
The above form is in Bootstrap Modal Box On Send button; I want to change the HTML 5 required validation.
I don't want the button type to be submitted. As page gets refreshed and the modal box is closed down ??
What can I do to validate HTML 5 without clicking on sumbit button?
Upvotes: 1
Views: 6273
Reputation: 444
You can use e.preventDefault()
to override default form action instead of using return false
.
Can be used with combination of form event submit
(or button event click
)
e.preventDefault();
See My JS Fiddle
Upvotes: 0
Reputation: 435
Thanks all for your replies..
I have done it successfully... with below script
$('button.saveChange').click(function(){
if (!$('#vehicleForm')[0].checkValidity()) {
$('#vehicleForm').find('input[type="submit"]').click();
return false;
}
});
Upvotes: 1