0

I am so upset, have been spending hours on this. Can you guys tell me whats wrong? Tried the onsubmit at the beginning at the end of the form. Changed it to onChange and onClick still the same issue.

I also cant get the Submit button to say a thank you message if I write an onclick function because it disables the onsubmit

<script type="text/javascript">
<!--
 // Form validation code will come here.
 function validate()
 {

 if( document.myForm.name.value == "" )
{
 alert( "Please provide your name!" );
 document.myForm.name.focus() ;
 return false;
 }
  if( document.myForm.email.value == "" )
 {
  alert( "Please provide your Email!" );
  document.myForm.email.focus() ;
 return false;
  }
 if( document.myForm.phone.value == "" ||
       isNaN( document.myForm.phone.value ) ||
       document.myForm.phone.value.length != 5 )
 {
   alert( "Please provide a phone number so we can reach you." );
   document.myForm.phone.focus() ;
    return false;
   }
return( true );
 }
   //-->
 </script>

<div class="iphorm-outer">
    <form class="iphorm" action="send_contact.php" name="myForm" method="post"  >
        <div class="iphorm-wrapper">
        <div class="iphorm-inner">
               <div class="iphorm-message"></div>
               <div class="iphorm-container clearfix">
                    <!-- Begin Name element -->
                    <div class="element-wrapper name-element-wrapper clearfix">
                        <label for="name">Name <span class="required">(required)</span></label>
                        <div class="input-wrapper name-input-wrapper">
                            <input class="name-element" id="name" type="text" name="name" />
                        </div>
                    </div>
                    <!-- End Name element -->
                    <!-- Begin Email element -->
                    <div class="element-wrapper email-element-wrapper clearfix">
                        <label for="email">Email <span class="required">(required)</span></label>
                        <div class="input-wrapper email-input-wrapper">
                            <input class="email-element" id="email" type="text" name="email" />
                        </div>
                    </div>
                    <!-- End Email element -->
                    <!-- Begin Phone element -->
                    <div class="element-wrapper phone-element-wrapper clearfix">
                        <label for="phone">Phone</label>
                        <div class="input-wrapper phone-input-wrapper">
                            <input class="phone-element" id="phone" type="text" name="phone" />
                        </div>
                    </div>
                    <!-- End Phone element -->
                    <!-- Begin Message element -->
                    <div class="element-wrapper message-element-wrapper clearfix">
                        <label for="message">Message <span class="required">(required)</span></label>
                        <div class="input-wrapper message-input-wrapper clearfix">
                            <textarea class="message-element" id="message" name="message" rows="7" cols="45"></textarea>
                        </div>
                    </div>
                    <!-- End Message element -->

                    <!-- Begin Submit button -->
                    <div class="button-wrapper submit-button-wrapper clearfix">
                        <div class="loading-wrapper"><span class="loading">Thank YOU, message sent.</span></div>
                        <div class="button-input-wrapper submit-button-input-wrapper">
                            <input class="ka-form-submit" type="submit" name="contact" onclick="return(validate())" value="Submit"/>
                        </div>
                    </div>
                    <!-- End Submit button -->
               </div>
           </div>
       </div>
    </form>

Can someone please help me write a function to disable Submit button unless function validate is true?

JsEveryDay
  • 313
  • 2
  • 5
  • 16

2 Answers2

0

Everything seems fine. Try to refresh the page using CTRL + F5 to clear browser's cache.

Helio Santos
  • 6,606
  • 3
  • 25
  • 31
  • You are right!! I tried it in ubuntu and it worked on chrome. Thanks for CTRL F5 I didnt know that. It still doesn't work on my windows chrome. Chrome is really weird, I had another website I was trying to use and chrome all of a sudden stooped allowing me to login, under F12 I saw that it was trying to download login.php instead of initiating the session. I cleaned ... uninstalled ...removed all addons and every possible thing and still didnt work. Until I wiped my drive and re-installed windows. I hate this browser as much as I love it – JsEveryDay Feb 07 '13 at 05:20
  • Can someone please help me write a function to disable Submit button unless function validate is true? – JsEveryDay Feb 07 '13 at 05:24
  • that is another question. Check this: http://stackoverflow.com/questions/3014649/how-to-disable-html-button-using-javascript – Helio Santos Feb 07 '13 at 11:07
0

enable script debugging in the browser advanced settings and try

Anuj
  • 1,496
  • 1
  • 18
  • 28
  • Couldnt find debugging on Chrome advance settings. – JsEveryDay Feb 07 '13 at 05:16
  • Thank you all, the script seems fine it just refuses to work on my browser. Can someone please help me write a function to disable Submit button unless function validate is true? – JsEveryDay Feb 07 '13 at 05:24