I am trying to learn jQuery and have stumbled across a strange problem (perhaps strange only to me). So here goes:
I have a form with id mainform
in my app. Now I wanted to validate the form with jQuery. Also I wanted to set the invalid fields in blue color. For that I added css
.error{
background-color:blue;
}
When I run $('form#mainform').valid();
in the console, I get the highlights and everything works fine. However when I run $('form#mainform').validate();
, I get lots of data and nothing happens.
Also if I run .valid()
before validate()
, various options such as error placement etc. don't seem to work.
I want to know the difference between these, why they are behaving so differently and where they should be used. I will appreciate if anyone can point me in right direction.
Note: I am using jquery.validate.js
The meaning of "valid" is given as "actually supporting the intended point or claim" from which "validate" is "to confirm the truth or value of".
confirm, corroborate, substantiate, verify, authenticate, validate mean to attest to the truth or validity of something.
To validate is to confirm, legalize, or prove the accuracy of something. Research showing that smoking is dangerous is an example of something that validates claims that smoking is dangerous.
The @Validated annotation is a class-level annotation that we can use to tell Spring to validate parameters that are passed into a method of the annotated class.
validate Add to list Share. To validate is to prove that something is based on truth or fact, or is acceptable. It can also mean to make something, like a contract, legal. You may need someone to validate your feelings, which means that you want to hear, “No, you're not crazy.
Validation Documentation means the collection of all documentation demonstrating that Product equivalence and all applicable regulatory requirements, and any other requirements agreed by the Parties, have been achieved with respect to a proposed new Facility, including master validation plans, qualification ...
There are several differences between valid and validate. Interestingly, although the docs state that
"validate needs to be called on the form before checking it using this method"
this isn't actually the case, as valid calls validate() anyway.
The two major differences are
valid can be called on a subset of form elements, whereas validate must be called on the form itself:
$('form').validate({/* options here */});
$('.myfields').valid()
Assuming you are using Jquery validate library.
Docs saying
validate() needs to be called on the form before checking it using valid() method.
Not .valid
() before validate
()
http://jqueryvalidation.org/valid/
http://jqueryvalidation.org/validate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With