0

I have a HTML form with input fields which are required, for example:

<input type="number" required="required" />

The submit button of my form is controlled by a jQuery event handler:

$('#submitButton').on('click', function(event){
  return false;
});

The fact that the submit button handler returns false leads to the problem that there is no automatic check for the required fields by the web browser. If I remove "return false" then there is a check (see screenshot) but then the page gets reloaded (which I don't want).

Is there a way, to use the browser's error correction without a page refresh after a form submit action?

enter image description here

1 Answer 1

1

I think you want to try something like:

$('#submitButton').on('click', function(event){
    return $("<some selector for the input>")[0].checkValidity();
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.