Advertisement
iameric

JS issue

Feb 7th, 2012
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 6.65 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <link rel="stylesheet" type="text/css" href="lib/styles2.css" />
  7. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
  8. <script type="text/javascript">
  9. function load(){
  10.         w.value = window.outerWidth;
  11.         h.value = window.outerHeight;
  12. }
  13.  
  14. // Allows for only one feedback topic to be selected
  15. $(function(){
  16.     $(".img-swap").live('click', function() {
  17.         this.src = this.src.replace('_off', '_on');
  18.             var topic = $(this).parent().attr('href');
  19.             htopic.value = topic.substr(1);
  20.         $('.img-swap').not(this).attr('src', function(index, attr) {
  21.             return attr.replace('_on', '_off');
  22.         });
  23.     });
  24. });
  25. // Grab
  26.  
  27. // Empties email input field onFocus
  28. function clickclear(thisfield, defaulttext) {
  29.     if (thisfield.value == defaulttext) {
  30.         thisfield.value = "";
  31.     }
  32. }
  33. // Refill email input field onBlur
  34. function clickrecall(thisfield, defaulttext) {
  35.     if (thisfield.value == "") {
  36.         thisfield.value = defaulttext;
  37.     }
  38. }
  39. // Submit form to next page
  40. function submitForm() {
  41.  //   document.forms["feedbackform"].submit();
  42.     document.feedbackform.submit();
  43. }
  44. // Submit form and validate email using RFC 2822 standard
  45. function validateEmail(email) {
  46.     // Modified version original from: http://stackoverflow.com/a/46181/11236
  47.     var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  48.     return re.test(email);
  49. }
  50. // Return true if email field is left unchanged
  51. function originalText(email){
  52.     var defaultMsg;
  53.     defaultMsg = "Enter your email address (optional)";
  54.     if(defaultMsg == email){
  55.         return true;   
  56.     }
  57.     return false;
  58. }
  59. // Verify or decline with error message
  60. function validate(){
  61.     $("#result").text("");
  62.     var email = $("#email").val();
  63.     if ((validateEmail(email)) || originalText(email)) {
  64.         submitForm();
  65.     } else {
  66.         $("#result").text(email + " is not a valid email.");
  67.         $("#result").css("color", "red");
  68.     }
  69.     return false;
  70. }
  71. $("feedbackform").bind("submit", validate);
  72. </script>
  73. </head>
  74. <body onload="load();">
  75. <div id="feedback"><form name="feedbackform" id="feedbackform" action="feedback-accept.php" onSubmit="javascript: validate(); return false;" method="post">
  76.     <div id="feedback-top">
  77.         <div id="feedback-header">Send Us Your Feedback</div>
  78.         <div id="feeback-top-subrow"><div id="feedback-customer-service">Need Help? Contact <a href="#">Customer Service</a>.</div><div id="feedback-header-sub">We'd love to hear your thoughts.</div></div>
  79.     </div>
  80.     <div id="feedback-divider"></div>
  81.     <div id="feedback-bottom">
  82.         <div class="feedback-subtitle">How do you feel about this site? <span class="feedback-sub">(optional)</span></div>
  83.             <div id="feeback-satisfied-bar">
  84.                     <label><div class="feeback-satisfied-bar-odd">1<br /><input type="radio" name="satisfaction" id="1" value="1" /></div></label>
  85.                     <label><div class="feeback-satisfied-bar-even">2<br /><input type="radio" name="satisfaction" id="2" value="2" /></div></label>
  86.                     <label><div class="feeback-satisfied-bar-odd">3<br /><input type="radio" name="satisfaction" id="3" value="3" /></div></label>
  87.                     <label><div class="feeback-satisfied-bar-even">4<br /><input type="radio" name="satisfaction" id="4" value="4" /></div></label>
  88.                     <label><div class="feeback-satisfied-bar-odd">5<br /><input type="radio" name="satisfaction" id="5" value="5" /></div></label>
  89.                     <label><div class="feeback-satisfied-bar-even">6<br /><input type="radio" name="satisfaction" id="6" value="6" /></div></label>
  90.                     <label><div class="feeback-satisfied-bar-odd">7<br /><input type="radio" name="satisfaction" id="7" value="7" /></div></label>
  91.                     <label><div class="feeback-satisfied-bar-even">8<br /><input type="radio" name="satisfaction" id="8" value="8" /></div></label>
  92.                     <label><div class="feeback-satisfied-bar-odd">9<br /><input type="radio" name="satisfaction" id="9" value="8" /></div></label>
  93.                     <label><div class="feeback-satisfied-bar-even">10<br /><input type="radio" name="satisfaction" id="10" value="10" /></div></label>
  94.                     <div id="feedback-satisfied-bar-end"></div>
  95.       </div>
  96.         <div class="feedback-subtitle">Feedback Topic? <span class="feedback-sub">Please select a category below...</span></div>
  97.         <div id="feedback-topic.buttons" style="padding-left: 2px;">
  98.         <a href="#bug"><img src="lib/feedback-bug_off.jpg" alt="bug" width="75" height="49" border="0" class="img-swap" /></a><a href="#content"><img src="lib/feedback-site_content_off.jpg" alt="site_content" width="121" height="49" border="0" class="img-swap" /></a><a href="#suggestion"><img src="lib/feedback-suggestion_off.jpg" alt="suggestion" width="117" height="49" border="0" class="img-swap" /></a><a href="#compliment"><img src="lib/feedback-compliment_off.jpg" alt="compliment" width="120" height="49" border="0" class="img-swap" /></a><a href="#checkout"><img src="lib/feedback-checkout_off.jpg" alt="checkout" width="107" height="49" border="0" class="img-swap" /></a><a href="#other"><img src="lib/feedback-other_off.jpg" alt="other" width="83" height="49" border="0" class="img-swap" /></a>
  99.         </div>
  100.         <div id="feedback-comment">
  101.             <textarea name="comments" rows="6" class="comment_info"></textarea>
  102.         </div>
  103.       <div id="feedback-comment-bottom"></div>
  104.         <div class="feedback-subtitle">Want us to follow up on your feedback? <span class="feedback-sub">(optional)</span></div>
  105.             <div id="feedback-followup"><div style="clear:both;"></div>
  106.                 <div id="feedback-submit"><span class="inner"><a href="#" class="feedback-cancel">Cancel</a> or </span><input type="image" src="lib/send_feedback.jpg" border="0" class="feedback-submit-img" onClick="javascript: validate(); return false;"/></div>
  107.               <div id="feedback-email"><input name="user_email" id="email" type="text" class="feedback-user_email" value="Enter your email address (optional)" onclick="clickclear(this, 'Enter your email address (optional)')" onblur="clickrecall(this,'Enter your email address (optional)')" /></div>
  108.       </div>
  109.   </div><input name="topic2" id="htopic" type="hidden" value="" /><input name="h" id="h" type="hidden" value="" /><input name="w" id="w" type="hidden" value="" /><input name="refer2" id="refer2" type="hidden" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" /></form>
  110.   <div><h2 id='result'></h2>
  111.   </div>
  112. </div>
  113. </body>
  114. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement