0
|
1 |
jQuery(document).ready(function() { |
|
2 |
|
|
3 |
//if submit button is clicked |
|
4 |
jQuery('.contact-form #submit').click(function () { |
|
5 |
|
|
6 |
//Get the data from all the fields |
|
7 |
var name = jQuery('input[name=name]'); |
|
8 |
var email = jQuery('input[name=email]'); |
|
9 |
var website = jQuery('input[name=website]'); |
|
10 |
var comment = jQuery('textarea[name=comment]'); |
|
11 |
|
|
12 |
//Simple validation to make sure user entered something |
|
13 |
//If error found, add hightlight class to the text field |
|
14 |
if (name.val()=='') { |
|
15 |
name.addClass('hightlight'); |
|
16 |
return false; |
|
17 |
} else name.removeClass('hightlight'); |
|
18 |
|
|
19 |
if (email.val()=='') { |
|
20 |
email.addClass('hightlight'); |
|
21 |
return false; |
|
22 |
} else email.removeClass('hightlight'); |
|
23 |
|
|
24 |
if (comment.val()=='') { |
|
25 |
comment.addClass('hightlight'); |
|
26 |
return false; |
|
27 |
} else comment.removeClass('hightlight'); |
|
28 |
|
|
29 |
//disabled all the text fields |
|
30 |
jQuery('.text').attr('disabled','true'); |
|
31 |
|
|
32 |
//show the loading sign |
|
33 |
jQuery('.loading').show(); |
|
34 |
|
|
35 |
jQuery.post("../wp-content/themes/SCRN/index.php", { name : name.val(), email : email.val(), comment : comment.val(), submit : "yes" }, function() { |
|
36 |
|
|
37 |
jQuery('.form').fadeOut('slow'); |
|
38 |
|
|
39 |
jQuery('.done').fadeIn('slow'); |
|
40 |
|
|
41 |
jQuery('.contact-form form').fadeOut('slow'); |
|
42 |
|
|
43 |
}); |
|
44 |
|
|
45 |
return false; |
|
46 |
|
|
47 |
//cancel the submit button default behaviours |
|
48 |
}); |
|
49 |
}); |