Simple jQuery Form Validator validation

Simple jQuery Form Validator validation

Today, We want to share with you Simple jQuery Form Validator validation.In this post we will show you Form validation with jQuery Validate, hear for jquery validate form before submit we will give you demo and example for implement.In this post, we will learn about jquery form validation demo with source code with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

Snippet Contents

Simple jQuery Form Validator validation

There are the Following The simple About Simple jQuery Form Validator validation Full Information With Example and source code.

As I will cover this Post with live Working example to develop jquery-validation/jquery-validation, so the jquery form validation demo for this example is following below.

A simple jQuery form validation script

index.html

<h2>A simple jQuery form validation script</h2>
<form id="userFrm" method="post" action="#">
   <textarea id="mon_textarea" name="montextarea"></textarea>
   <input type="email" id="mon_email" name="useremail" />
   <input type="email" id="mon_telephone" name="telephone" />
   <input type="submit" value="ok" id="btn_submit" />
</form>

jQuery validate the form

<script>
   $(document).ready(function(){
      $("#userFrm").validate();
    });
</script>

jQuery Form Validation syntax:

jQuery(document).ready(function() {
   jQuery("#formStep").validate({
      rules: {
         "montextarea":{
            "required": true,
            "minlength": 2,
            "maxlength": 60000
         },
         "useremail": {
            "email": true,
            "maxlength": 255
         },
         "telephone": {
            "required": true
         }
  })
});

jQuery Define error errorInfos

  jQuery.extend(jQuery.validator.errorInfos, {
    required: "product errorInfo",
    remote: "product errorInfo",
    email: "product errorInfo",
    url: "product errorInfo",
    date: "product errorInfo",
    dateISO: "product errorInfo",
    number: "product errorInfo",
    digits: "product errorInfo",
    creditcard: "product errorInfo",
    equalTo: "product errorInfo",
    accept: "product errorInfo",
    maxlength: jQuery.validator.format("product errorInfo {0} caractéres."),
    minlength: jQuery.validator.format("product errorInfo {0} caractéres."),
    rangelength: jQuery.validator.format("product errorInfo  entre {0} et {1} caractéres."),
    range: jQuery.validator.format("product errorInfo  entre {0} et {1}."),
    max: jQuery.validator.format("product errorInfo  inférieur ou égal à {0}."),
    min: jQuery.validator.format("product errorInfo  supérieur ou égal à {0}.")
  });

jQuery Add Method Simple Regular Expression (regex)

jQuery.validator.addMethod(
  "regex",
   function(value, element, regexp) {
       if (regexp.constructor != RegExp)
          regexp = new RegExp(regexp);
       else if (regexp.global)
          regexp.lastIndex = 0;
          return this.optional(element) || regexp.test(value);
   },"erreur expression reguliere"
);

Phone regex

"telephone": {
    "required": true,
    "regex": /^(\+33\.|0)[0-9]{9}$/
}

jQuery Change a behaviour

rules:{
    ...
},
submitHandler: function(form)
{
    /* jQuery Form Submit Data */
    jQuery("#btn_submit").hide();
}

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 Simple jQuery Form Validator validation.
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.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Validate is not a function in laravel
  2.   Angular js Introduction to Looping Statements
  3.   Laravel 6 try catch Database Transaction
  4.   PHP Send HTML Email Table Format Template
  5.   Basic JQuery Form Validation Example
  6.   How to Open URL in New Tab using ASP.NET
  7.   Angular 6 Services Tutorial with Examples
  8.   jQuery CDN Link Cheat Sheet Download
  9.   jQuery Form Validator Script
  10.   how to get last inserted id in laravel 6