By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,848 Members | 3,202 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,848 IT Pros & Developers. It's quick & easy.

Javascript Validation - Verify there is a name entered in forms text box

P: 67
Hello,

I have a form that i use ASP to process the form to my access database. It works well but I'm struggling to get the javascript validation to work. I have posted a small version of my form to see if any of you know why this isn't working. I believe this is supposed to have a box pop up to say "You must enter a first name." when you leave the text box blank. However, I get nothing. Any thoughts are greatly appreciated. Thanks - Jerry

Expand|Select|Wrap|Line Numbers
  1. <html><head><title>Registration Page</title>
  2. <script Language="JavaScript">
  3. <!--
  4. function Form1_Validator(theForm)
  5. {
  6. if (theForm.firstname.value == "")
  7. {
  8. alert(You must enter a First Name.");
  9. theForm.firstname.focus();
  10. return (false);
  11. }
  12. }
  13. //--></script>
  14.  
  15. </head>
  16.  
  17. <form method="post" action="register_users.asp" onsubmit="return Form1_Validator(this)">
  18.  
  19. <p><pre>
  20. <h3><font color="navy">Step 1: User Information</font></h3>
  21. <p><b><font face="comic sans ms">First Name:    <input type="text" name="firstname" size="25"/>
  22.  
  23. <input type="submit" value="Click here to Register"/>
  24. <input type="reset" value="Erase and Start Over"/></p>
  25. </form>
  26. </body>
  27. </html>
Nov 2 '08 #1
Share this Question
Share on Google+
1 Reply


P: 67
please disregard my last post, i was way off but i have figured out the answer.
thanks for looking thought, take care
Nov 2 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.