-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathform-validation.js
58 lines (53 loc) · 1.67 KB
/
form-validation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//Library for validation
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.16.0/jquery.validate.min.js"></script>
<form id="form1" name="form1" action="">
<div><input type="name" name="name" id="name">
<span class="help-inline"> </span>
<div>
<input type="email" name="email" id="email">
<span class="help-inline"> </span>
</div>
<div>
<input type="password" name="password_confirmation" id="password_confirmation">
<span class="help-inline"> </span>
</div>
</form>
// Custom Js Valdiation to id name of html form
$(document).ready(function () {
var v = $("#form1").validate({
rules: {
name: {
required: true,
minlength: 2,
maxlength: 100
},
email: {
required: true,
minlength: 2,
email: true,
maxlength: 50
},
// confirmed password
password_confirmation: {
minlength: 6,
maxlength: 50,
equalTo: "#password",
}
},
// custom messeage show
messages: {
name:{
equalTo: "Please Enter your name",
}
},
errorElement: "span",
errorClass: "help-inline",
});
});
<style>
.help-inline {
color: red;
font-size: 15px;
font-weight: 500;
}
</style>