-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidationjs.js
46 lines (40 loc) · 1.16 KB
/
validationjs.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
//CUSTOM FUNCTIONS ---------
$.validator.addMethod("alpha", function(value, element) {
return this.optional(element) || value == value.match(/^[a-zA-Z]+$/);
}, "Letters only Please");
$.validator.addMethod("au_post", function(value, element) {
return this.optional(element) || value == value.match(/[0-9]{3,4}/);
}, "Valid Postcode Please");
//------END CUSTOM FUNCTIONS--------------
$(document).ready(function () {
$('#myform').validate({ // initialize the plugin
rules: {
email: {
required: false,
email: true
},
text: {
required: false,
minlength: 2,
maxlength: 300,
alpha: true
},
phone: {
required: false,
digits: true
},
postcode: {
required: false,
digits: true,
au_post: true
},
domain: {
required: false,
minlength: 7
},
},
submitHandler: function (form) {
return true;
}
});
});