Tuesday 9 February 2016

Jquery form validation using library

Jquery form validation: The first thing is when we create the form for retrieving some data from the user then the user will enter the data in data fields that we created and so for we need to retrieve the correct data from our user. For that purpose, we use the form validation. Different types of form validation occur like using jquery form_validatiaon.js library, PHP form validation, CodeIgniter form validation. So we discuss the form validation using jquery-validation-1.14.0 that is the simple and easy to use and accurate and most of the professionals use this type of validation.

Jquery form validation using library

Example:
Two steps
step 1) Create the form and in the form, tag writes the tag novalidate="novalidate"
step 2) the jquery form validation functions.

--------------------------------------------------------------------------------------

  <form method="post" action="http://192.168.1.200/projects/NomanJ/dbcontroller/add" id="formSubmit" novalidate="novalidate">
    <div class="form-group">
      <label for="firstname">First Name</label>
      <input type="text" name="firstname" class="form-control" id="firstname" placeholder="firstname">
    </div>
    <div class="form-group">
      <label for="lastname">Last Name</label>
      <input type="text" name="lastname" class="form-control" id="lastname" placeholder="lastname">
    </div>
    <div class="form-group">
      <label for="email">Email</label>
      <input type="email" name="email" class="form-control" id="email" placeholder="example@gmail.com">
    </div>
    <button type="submit" class="btn btn-default">Submit</button>
  </form>


--------------------------------------------------------------------------------------

<script>
// manual method
/*
$("#formSubmit").submit(function(e){
  if($("#firstname").val('') && $("#lastname").val('') && $("#email").val('') ){
});
*/
// js form validation
  $("#formSubmit").validate({
    // Specify the validation rules
    rules:{
      firstname: "required",
 
      email:{
        required: true,
        email: true
      },
    },
    messages:{
      firstname: "Please enter your first name",
      lastname: "Please enter your last name",
      email: "Please enter the valid email",
    }
  });
</script>
--------------------------------------------------------------------------------------

Jquery form validation using library

Here is the jquery validation library used for the validation purpose so that the people enter the write content / context that is acceptable by the developer system/software system. There are many methods for the validation of the forms data like PHP validation that is also called server-side validation and HTML 5 validation that is the browser side validation but the HTML 5 validation only work in the new web browsers/ internet browsers. So the developers and testers prefer to implement the jquery validation and PHP server side validation both at a time. You can also see out PHP server side validation on our site.
Codeigniter form validation ....!

This Post Was Last Updated On September 30, 2016, By Author: Mahira Khan.

0 comments:

Post a Comment

Item Reviewed: Jquery form validation using library Rating: 5 Reviewed By: admin