jquery validation is a pattern of checking of input desired code user need a standard library of validation method and include the file into the same folder. it is a process of ensuring that computer input is clean and correct by using the rules and message to it. it will describing the error when user give wrong input.
<html>
<body>
<form id="login_form" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">email</label>
<div class="col-sm-9">
<input type="email" class="form-control" placeholder="email" name="email">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Password</label>
<div class="col-sm-9">
<input type="password" class="form-control" placeholder="Password" name="password">
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery.validate.min.js"></script>
<script src="form.js"></script>
<script type="text/javascript">
$( "#login_form" ).validate({
rules: {
email: {
required: true,
email: true,
remote: {
url: "check-email.php",
type: "post",
data: {
username: function() {
return $( "#username" ).val();
}
}
}
}
}
});
</script>
</body>
</html>
This function check the uniqueness of a username and returns an error if not unique.So when users form submits, it passes the $_POST array to this page.
0 Comment(s)