Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

JS

By: a guest on Mar 16th, 2012  |  syntax: None  |  size: 1.41 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!-- *************************************************************************
  2. *********************  THIS IS THE CONTACT FORM JS  **************************
  3. ************************************************************************** -->
  4.  
  5. <script type='text/javascript'>
  6.  
  7. $(document).ready(function(){
  8. var active_color = '#929191'; // Colour of user provided text
  9. var inactive_color = '#929191'; // Colour of default text
  10. $("input.default-value").css("color", inactive_color);
  11. var default_values = new Array();
  12. $("input.default-value").focus(function() {
  13. if (!default_values[this.id]) {
  14. default_values[this.id] = this.value;
  15. }
  16. if (this.value == default_values[this.id]) {
  17. this.value = '';
  18. this.style.color = active_color;
  19. }
  20. $(this).blur(function() {
  21. if (this.value == '') {
  22. this.style.color = inactive_color;
  23. this.value = default_values[this.id];
  24. }
  25. });
  26. });
  27.  
  28. $('#contactform').submit(function(){
  29.  
  30. formvalues = $("#contactform").serialize();
  31.  
  32. $.ajax({
  33. type: "POST",
  34. url: "mailer.php",
  35. data: formvalues,
  36. dataType: "json",
  37. success: function(data) {
  38. if (data.success==1) {
  39. $("#contactwrapper").slideUp(750,function() {
  40. $('#contactmessage').html('Thanks! Please check your email to confirm your subscription.');
  41. });
  42. }
  43. else{
  44. if (data.invalid_email==1) { $('#contact_email').addClass("form_error"); }
  45. else { $('#contact_email').removeClass("form_error"); }
  46.  
  47. }
  48. }
  49. });
  50. return false;
  51. });
  52.  
  53. });
  54. </script>