0

In the examples they all show calling something like this.

$('#myform').validate(
  rules: {
    myfield: 'required'
  }
)

However, in my pages when that's all I call it doesn't actually validate the form and show error messages (like in the examples). I have to add a call to $('#myform').valid() to get it to show validation the errors.

I'm using JQuery Validator 1.9.5 with JQuery 3.7.1.

Here's a stackblitz showing the issue.

You can modify the code to uncomment the call to form.valid() to see that it validates.

2
  • 1
    .validate() is the initialization. .valid() is a trigger to validate, but it's not required. If you set it up correctly, clicking the submit button is also a trigger. Instead of linking to the code, you should be posting it here. I suggest you review the official documentation website for the plugin as well as the numerous questions tagged on SO. Commented Apr 3 at 22:37
  • 1
    I looked at your code. If you change your button into a type="submit", then you won't need to call .valid(). Again, this is all laid out in the documentation. Commented Apr 3 at 22:40

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.