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>
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