-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.html
46 lines (37 loc) · 960 Bytes
/
example.html
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
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="src/jquery.validator.js"></script>
<script>
$(function(){
$('form').submit(function(e){
e.preventDefault();
$('form input').css('border', '3px solid blue');
var contactForm = $(this).validator({
'name' :'required|max:12|alpha_dash',
'email' : 'required|email'
});
contactForm.fails(function( errors ){
errors.allElements().each(function(){
console.log($(this).data('messages'));
});
errors.allElements().css('border', '3px solid red');
});
contactForm.passes(function(){
$(this).submit();
});
});
});
</script>
</head>
<body>
<div>
<form>
<p><input name="name" placeholder="test" /></p>
<p><input name="email" placeholder="test" /></p>
<p><input name="Phone Number" placeholder="test" /></p>
<p><input name="foo" placeholder="test" /></p>
<button>Go!</button>
</form>
</body>
</html>