Today, We want to share with you jQuery Regular Expression Real Time Form Validation Example.In this post we will show you Jquery Validation with Regular Expressions, hear for password validation in jquery using regular expression we will give you demo and example for implement.In this post, we will learn about Real Time Form Validation using Regular Expressions in jQuery with an example.
jQuery Regular Expression Real Time Form Validation Example
There are the Following The simple About jQuery Regular Expression Real Time Form Validation Example Full Information With Example and source code.
As I will cover this Post with live Working example to develop jquery regular expression validation for special characters, so the some major files and Directory structures for this example is following below.
- URL
- Username
- Password
- Strong Password
Email validation in jquery using regular expression
Email Checking using Regular Expression
Regular Expression with jQuery Validation
function checkLiveEmail(email) { //jQuery Regular Expression Real Time Form Validation Example var liveStrongPtrn = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); if(liveStrongPtrn.test(email)){ return true; } else { return false; } }
simple JavaScript regular expression for email validation
var liveStrongPtrn = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
Output – Results
admin.email.com = Error [email protected] = Ok
URL validation in jquery using regular expression
URL Check using Regular Expression
http or https with URL
function checkUrl(url) { //regular url expression for URL var liveStrongPtrn = /^(http|https)?:\/\/[a-zA-Z0-9-\.]+\.[a-z]{2,4}/; if(liveStrongPtrn.test(url)){ return true; } else { return false; } }
Output – Results
www.pakainfo.com = Error https://www.pakainfo.com = Ok http://www.pakainfo.com = Ok
Username validation in jquery using regular expression
Username Check using Regular Expression
accept 5-15 characters without any symbol or special characters
function checkLiveFirstname(username){ var liveStrongPtrn = /^[a-z0-9_-]{5,15}$/; if(liveStrongPtrn.test(username)){ return true; }else{ return false; } }
Output – Results
Result: jaydeep.gondaliya = Error jaydeep123 = Ok
password validation in jquery using regular expression
Password using Regular Expression
accept 6-18 lowercase, uppercase, characters, numbers
function checkPassword(password){ var liveStrongPtrn = /^[a-zA-Z0-9_-]{6,18}$/; if(liveStrongPtrn.test(password)){ return true; }else{ return false; } }
Output – Results
Result: JdPaka = Ok jd@Paka = Error
Strong Password using Regular Expression
- Must be at least 8 characters
- At least 1 number, 1 lowercase, 1 uppercase letter
- At least 1 special character from @#$%&
var liveStrongPtrn = /^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%&]).*$/;
Output – Results
Result: JdPaka@123 = Ok jd@Paka = Error
jQuery Regular Expression Real Time Form Validation Example – Outout
Angular 6 CRUD Operations Application Tutorials
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about jQuery Regular Expression Real Time Form Validation Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.