You can simply use the jQuery Validate plugin as follows.

jQuery:

$(document).ready(function () {

    $('#myform').validate({ // initialize the plugin
        rules: {
            field1: {
                required: true,
                email: true
            },
            field2: {
                required: true,
                minlength: 5
            }
        }
    });

});

HTML:

<form id="myform">
    <input type="text" name="field1" />
    <input type="text" name="field2" />
    <input type="submit" />
</form>

DEMO: http://jsfiddle.net/xs5vrrso/

Options: http://jqueryvalidation.org/validate

Methods: http://jqueryvalidation.org/category/plugin/

Standard Rules: http://jqueryvalidation.org/category/methods/

Optional Rules available with the additional-methods.js file:

maxWords
minWords
rangeWords
letterswithbasicpunc
alphanumeric
lettersonly
nowhitespace
ziprange
zipcodeUS
integer
vinUS
dateITA
dateNL
time
time12h
phoneUS
phoneUK
mobileUK
phonesUK
postcodeUK
strippedminlength
email2 (optional TLD)
url2 (optional TLD)
creditcardtypes
ipv4
ipv6
pattern
require_from_group
skip_or_fill_minimum
accept
extension
Answer from Sparky on Stack Overflow
🌐
Jqueryvalidation
jqueryvalidation.org
jQuery Validation Plugin | Form validation with jQuery
This jQuery plugin makes simple clientside form validation easy, whilst still offering plenty of customization options. It makes a good choice if you’re building something new from scratch, but also when you’re trying to integrate something into an existing application with lots of existing ...
Reference documentation
Apart from required itself and equalTo, all validation methods declare an element valid when it has no value at all. That way an email field is optional unless required is specified. You can specify an element input to contain a valid email address, or nothing at all. Use jQuery.validator.addMethod ...
Documentation
There is also an article discussing how this plugin fits the bill of the should-be validation solution. ... A single line of jQuery to select the form and apply the validation plugin, plus a few annotations on each element to specify the validation rules.
🌐
GitHub
github.com › jquery-validation › jquery-validation
GitHub - jquery-validation/jquery-validation: jQuery Validation Plugin library sources · GitHub
The jQuery Validation Plugin provides drop-in validation for your existing forms, while making all kinds of customizations to fit your application really easy.
Starred by 10.3K users
Forked by 2.7K users
Languages   JavaScript 95.5% | HTML 4.5%
Discussions

jQuery Validation
Ask questions here if you're new to jQuery or JavaScript and need help making sense of it all · Ask questions and report issues related to using jQuery. Discuss anything related to jQuery itself. For issues with plugins, ask in the jQuery Plugins forum · Want to discuss the forum itself? More on forum.jquery.com
🌐 forum.jquery.com
A simple jQuery form validation script - Stack Overflow
I made a simple validation form using jQuery. It's working alright. The thing is I'm not satisfied with my code. Is there another way around to write my code with the same output result? $(document). More on stackoverflow.com
🌐 stackoverflow.com
jQuery Validation
Not sure if you really want to add jquery at all but it's definitely worth it to use js to your advantage to speed up field validation. More on reddit.com
🌐 r/dotnet
10
0
April 20, 2024
How to manually trigger validation with jQuery validate?
I want to manually trigger validation including showing error messages with jQuery Validate. The scenario I am trying to accomplish is a form like this: More on stackoverflow.com
🌐 stackoverflow.com
🌐
NuGet
nuget.org › packages › jquery.validation
NuGet Gallery | jQuery.Validation 1.21.0
This jQuery plugin makes simple clientside form validation trivial, while offering lots of option for customization. That makes a good choice if you’re building something new from scratch, but also when you’re trying to integrate it into an existing application with lots of existing markup.
🌐
W3Schools
w3schools.com › js › js_validation.asp
W3Schools.com
jQuery Selectors jQuery HTML jQuery CSS jQuery DOM JS Graphics · JS Graphics JS Canvas JS Plotly JS Chart.js JS Google Chart JS D3.js JS Examples · JS Examples JS HTML DOM JS HTML Input JS HTML Objects JS HTML Events JS Browser JS Editor JS Exercises JS Quiz JS Website JS Syllabus JS Study Plan JS Interview Prep JS Bootcamp JS Certificate JS Reference ... HTML form validation can be done by JavaScript.
🌐
Jquery
forum.jquery.com › portal › en › community › topic › jquery-validation
jQuery Validation
Ask questions here if you're new to jQuery or JavaScript and need help making sense of it all · Ask questions and report issues related to using jQuery. Discuss anything related to jQuery itself. For issues with plugins, ask in the jQuery Plugins forum · Want to discuss the forum itself?
Top answer
1 of 2
324

You can simply use the jQuery Validate plugin as follows.

jQuery:

$(document).ready(function () {

    $('#myform').validate({ // initialize the plugin
        rules: {
            field1: {
                required: true,
                email: true
            },
            field2: {
                required: true,
                minlength: 5
            }
        }
    });

});

HTML:

<form id="myform">
    <input type="text" name="field1" />
    <input type="text" name="field2" />
    <input type="submit" />
</form>

DEMO: http://jsfiddle.net/xs5vrrso/

Options: http://jqueryvalidation.org/validate

Methods: http://jqueryvalidation.org/category/plugin/

Standard Rules: http://jqueryvalidation.org/category/methods/

Optional Rules available with the additional-methods.js file:

maxWords
minWords
rangeWords
letterswithbasicpunc
alphanumeric
lettersonly
nowhitespace
ziprange
zipcodeUS
integer
vinUS
dateITA
dateNL
time
time12h
phoneUS
phoneUK
mobileUK
phonesUK
postcodeUK
strippedminlength
email2 (optional TLD)
url2 (optional TLD)
creditcardtypes
ipv4
ipv6
pattern
require_from_group
skip_or_fill_minimum
accept
extension
2 of 2
19

you can use jquery validator for that but you need to add jquery.validate.js and jquery.form.js file for that. after including validator file define your validation something like this.

<script type="text/javascript">
$(document).ready(function(){
    $("#formID").validate({
    rules :{
        "data[User][name]" : {
            required : true
        }
    },
    messages :{
        "data[User][name]" : {
            required : 'Enter username'
        }
    }
    });
});
</script>

You can see required : true same there is many more property like for email you can define email : true for number number : true

Find elsewhere
🌐
Kaylee42
kaylee42.github.io › blog › 2016 › 02 › 11 › intro-to-the-jquery-validation-plugin
Intro to the jQuery Validation Plugin - there be code here
It provides easy, immediate validation on forms, analyzing user input as they type and providing instant feedback on validation failures in addition to preventing a form from submitting if it contains any invalid data. However, I found the documentation a little lacking, especially for a JavaScript/jQuery beginner like myself.
🌐
cdnjs
cdnjs.com › home › libraries › jquery-validate
jquery-validate - Libraries - cdnjs - The #1 free and open source CDN built to make life easier for developers
jquery-validate · Client-side form validation made easy · 10k · GitHub · MIT licensed · http://jqueryvalidation.org/ Tags: jQuery, forms, validate, validation · Version · 1.21.0 · Loading... Asset Type · All · Loading... Some files are hidden, click to show all files ·
🌐
SitePoint
sitepoint.com › blog › javascript › how to set up basic jquery form validation in two minutes
jQuery Form Validation Tutorial: Simple Example with jQuery Validation Plugin | SitePoint
January 6, 2025 - For example, you can create a basic form with input fields for user information and use the plugin to validate this information. To style the form, create a new CSS file and include it in the head section of your HTML code. Then, initialize the jQuery validation on form submit in a new JavaScript(JS) file, specifying each input field’s validation rules and error messages.
🌐
DevExtreme
js.devexpress.com › jQuery › Demos › WidgetsGallery › Demo › Validation › Overview
JavaScript/jQuery Validation - Overview | jQuery/JS Example
'password' : 'text'); }; $('#summary').dxValidationSummary({ }); $('#email-validation').dxTextBox({ inputAttr: { 'aria-label': 'Email' }, }) .dxValidator({ validationRules: [{ type: 'required', message: 'Email is required', }, { type: 'email', message: 'Email is invalid', }, { type: 'async', message: 'Email is already registered', validationCallback(params) { return sendRequest(params.value); }, }], }); $('#password-validation').dxTextBox({ mode: 'password', inputAttr: { 'aria-label': 'Password' }, onValueChanged() { const editor = $('#confirm-password-validation').dxTextBox('instance'); if (e
🌐
SourceForge
sourceforge.net › projects › jquery-validation.mirror
jQuery Validation Plugin download | SourceForge.net
February 18, 2026 - Download jQuery Validation Plugin for free. jQuery Validation Plugin library sources. The jQuery Validation Plugin provides drop-in validation for your existing forms, while making all kinds of customizations to fit your application really easy.
🌐
GitHub
github.com › posabsolute › jQuery-Validation-Engine
GitHub - posabsolute/jQuery-Validation-Engine: jQuery form validation plugin · GitHub
onlyNumber, onlyLetter and validate2fields are all selectors. jQuery.validationEngine comes with a standard set but you are welcome to add you own to define AJAX backend services, error messages and/or new regular expressions.
Starred by 2.5K users
Forked by 1.2K users
Languages   JavaScript 98.5% | CSS 1.5%
🌐
Reddit
reddit.com › r/dotnet › jquery validation
r/dotnet on Reddit: jQuery Validation
April 20, 2024 -

Hello everyone, I have a very simple beginner question. I am new to .NET and to web developpement in general, so I started with the razor pages tutorial, the mvc tutorial and the Contoso University/Entity Framework tutorial. They were globally very clear and simple, but one thing that really annoyed me was the issue with globalization and jquery validation for foreign locales (french in my case).

I was so annoyed by it because that was not what I came for in the first place, so I ended up deleting all the jquery files and any reference to them in the project, and it worked perfectly. So far I've been doing that and handling validation server-side. However, I'm not quite sure if it is really important to also have client side validation as well ? Should I try to stick to jQuery validation, or would server-side validation be enough ?

🌐
Jqueryvalidation
jqueryvalidation.org › rules
.rules() | jQuery Validation Plugin
May 23, 2013 - Adds the specified rules and returns all rules for the first matched element. Requires that the parent form is validated, that is, $( "form" ).validate() is called first or
🌐
Snyk
security.snyk.io › snyk vulnerability database › npm
jquery-validation vulnerabilities | Snyk
We found that jquery-validation demonstrates a positive version release cadence with at least one new version released in the past 3 months.
🌐
GeeksforGeeks
geeksforgeeks.org › jquery › form-validation-using-jquery
Form Validation using jQuery - GeeksforGeeks
July 15, 2025 - Form validation is a process of confirming the relevant information entered by the user in the input field. In this article, we will be validating a simple form that consists of a username, password, and a confirmed password using jQuery.
🌐
Formspree
formspree.io › blog › jquery-validate
Mastering Form Validation with jQuery Validate | Formspree
January 13, 2025 - While server-side validation is non-negotiable for security, relying solely on it can lead to performance bottlenecks and a suboptimal user experience. Enter jQuery Validate, a widely used client-side validation library.
🌐
Utilities and Tools
utilities-online.info › jquery-validator
JQuery Validator
JQuery Validator · JQuery Validator · Help us make tools better by telling us your review about this tool · Your Feedback submitted successfully. "Tool functionality is good." Continue · Back · View a reference table of ASCII characters and their corresponding codes.