Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VERY URGENT. Simple validation.

Status
Not open for further replies.

Amara82

Programmer
Jun 26, 2003
6
GB
Hi, I have designed a page through which a user will be able send it's comment to me. It has few fields that i want to validate. Can someone check my coding and tell me what's wrong with it. I need it really fast. THANK YOU.
<HTML>
<HEAD>
<!--Hide javascript from browser-->
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>

function checkEmail()
{
Var userName = document.frmcontact.textfield1.value;
var userEmail = document.frmcontact.textfield2.value;
var userComment = document.frmcontact.textfield3.value;
if (userName == &quot;&quot;)
{
alert(&quot;Please fill in the text box&quot;);
document.frmcontact.textfield1.focus();
return false;

}
if (userEmail == &quot;&quot;)
{
alert(&quot;Please fill in the text box&quot;);
document.frmcontact.textfield2.focus();
return false;
} else if (userEmail.indexOf(&quot;@&quot;)==-1 || userEmail.indexOf(&quot; &quot;)!=-1) {
alert(&quot;Sorry, your e-mail address is invalid&quot;);
document.subscribe.email.focus();
return false;
}

if (userComment == &quot;&quot;)
{
alert(&quot;Please enter your suggestions, comments or questionns. Thank you!&quot;);
document.frmcontact.textfield3.focus();
return false;
}
}

</SCRIPT>
<TITLE>contactus</TITLE> <META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=iso-8859-1&quot;>
</HEAD>

<BODY BGCOLOR=&quot;#FFFFCC&quot; onLoad=&quot;initVars()&quot;>
<TABLE WIDTH=&quot;75%&quot; BORDER=&quot;1&quot; HEIGHT=&quot;590&quot;><TR><TD HEIGHT=&quot;104&quot;>&nbsp;</TD></TR><TR><TD HEIGHT=&quot;638&quot;><DIV ID=&quot;Layer2&quot; STYLE=&quot;position:absolute; width:153px; height:60px; z-index:2; left: 30px; top: 26px&quot;><IMG SRC=&quot;Image/logo.gif&quot; WIDTH=&quot;152&quot; HEIGHT=&quot;85&quot;></DIV><DIV ID=&quot;Layer14&quot; STYLE=&quot;position:absolute; width:200px; height:49px; z-index:6; left: 188px; top: 45px&quot;><DIV ALIGN=&quot;CENTER&quot;><B><FONT SIZE=&quot;6&quot; COLOR=&quot;#FFFF99&quot;>Contact
Us! </FONT></B></DIV></DIV><FORM action=&quot; method=&quot;POST&quot; NAME=&quot;frmcontact&quot; onSubmit=&quot;return checkEmail();&quot;>
<INPUT TYPE=&quot;hidden&quot; NAME=&quot;your_email_address&quot; VALUE=&quot;ammara_masood@hotmail.com&quot;>
<INPUT TYPE=&quot;hidden&quot; NAME=&quot;your_name&quot; VALUE=&quot;KIdz Own Club&quot;> <INPUT TYPE=&quot;hidden&quot; NAME=&quot;email_subject_line&quot; VALUE=&quot;Contact Us&quot;>
<INPUT TYPE=&quot;hidden&quot; NAME=&quot;required_fields&quot; VALUE=&quot;your_email_address&quot;> <INPUT TYPE=&quot;hidden&quot; NAME=&quot;thank_you_title&quot; VALUE=&quot;Thank you for completing the form! We will get back to you as soon as possible. &quot;>
<INPUT TYPE=&quot;hidden&quot; NAME=&quot;return_link_url&quot; VALUE=&quot;<INPUT TYPE=&quot;hidden&quot; NAME=&quot;return_link_name&quot; VALUE=&quot;Homepage&quot;> <INPUT TYPE=&quot;hidden&quot; NAME=&quot;background_color&quot; VALUE=&quot;#FFFFFF&quot;>
<INPUT TYPE=&quot;hidden&quot; NAME=&quot;text_color&quot; VALUE=&quot;#FF0000&quot;> <INPUT TYPE=&quot;hidden&quot; NAME=&quot;link_color&quot; VALUE=&quot;#008000&quot;>
<INPUT TYPE=&quot;hidden&quot; NAME=&quot;visited_link_color&quot; VALUE=&quot;#FF0000&quot;> <INPUT TYPE=&quot;hidden&quot; NAME=&quot;active_link_color&quot; VALUE=&quot;#008000&quot;><P>&nbsp;</P><P>&nbsp;</P><DIV ID=&quot;Layer3&quot; STYLE=&quot;position:absolute; width:593px; height:32px; z-index:3; left: 19px; top: 159px&quot;><FONT COLOR=&quot;#FF0000&quot;>Send
us your comments or suggestions about the website. Your comments will be appreciated.
</FONT><DIV ID=&quot;Layer4&quot; STYLE=&quot;position:absolute; width:71px; height:34px; z-index:4; left: 111px; top: 46px&quot;><FONT COLOR=&quot;#FF0000&quot;>Nam</FONT><DIV ID=&quot;Layer9&quot; STYLE=&quot;position:absolute; width:200px; height:35px; z-index:5; left: 73px; top: 39px&quot;><SELECT NAME=&quot;select1&quot;><OPTION>Suggestion</OPTION><OPTION>Comment</OPTION><OPTION>Questionn</OPTION></SELECT></DIV><DIV ID=&quot;Layer10&quot; STYLE=&quot;position:absolute; width:200px; height:29px; z-index:7; left: 73px; top: 77px&quot;><INPUT TYPE=&quot;text&quot; NAME=&quot;textfield2&quot;><DIV ID=&quot;Layer11&quot; STYLE=&quot;position:absolute; width:200px; height:115px; z-index:1; left: 2px; top: 31px&quot;><TEXTAREA NAME=&quot;textfield3&quot; ROWS=&quot;10&quot; COLS=&quot;40&quot;></TEXTAREA><DIV ID=&quot;Layer12&quot; STYLE=&quot;position:absolute; width:200px; height:40px; z-index:1; left: 2px; top: 194px&quot;><INPUT TYPE=&quot;submit&quot; NAME=&quot;Submit&quot;

VALUE=&quot;Submit&quot;><INPUT TYPE=&quot;reset&quot; VALUE=&quot;Reset&quot; NAME=&quot;Reset&quot;></DIV></DIV></DIV><FONT COLOR=&quot;#FF0000&quot;>e:</FONT>
<DIV ID=&quot;Layer5&quot; STYLE=&quot;position:absolute; width:74px; height:35px; z-index:4; left: -3px; top: 38px&quot;><FONT COLOR=&quot;#FF0000&quot;>This
is a:</FONT></DIV><DIV ID=&quot;Layer6&quot; STYLE=&quot;position:absolute; width:171px; height:29px; z-index:5; left: -99px; top: 78px&quot;><FONT COLOR=&quot;#FF0000&quot;>E-mail
Address (Required):</FONT></DIV><DIV ID=&quot;Layer7&quot; STYLE=&quot;position:absolute; width:160px; height:31px; z-index:6; left: -88px; top: 114px&quot;><FONT COLOR=&quot;#FF0000&quot;>Suggestion
or a comment: </FONT></DIV></DIV><FONT COLOR=&quot;#FF0000&quot;> </FONT></DIV><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><DIV ID=&quot;Layer8&quot; STYLE=&quot;position:absolute; width:200px; height:39px; z-index:4; left: 202px; top: 204px&quot;><INPUT TYPE=&quot;text&quot; NAME=&quot;textfield1&quot;></DIV><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><DIV ID=&quot;Layer13&quot; STYLE=&quot;position:absolute; width:71px; height:45px; z-index:5; left: 671px; top: 538px; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000&quot;><A HREF=&quot;Homepage.htm&quot;><IMG SRC=&quot;Image/home.gif&quot; WIDTH=&quot;69&quot; HEIGHT=&quot;66&quot; BORDER=&quot;0&quot;></A></DIV><P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;<BLOCKQUOTE><P>&nbsp;</P></BLOCKQUOTE></FORM></TD></TR></TABLE><DIV ID=&quot;Layer1&quot; STYLE=&quot;position:absolute; width:730px; height:103px; z-index:1; left: 15px; top: 18px; background-color: #FFFFCC; layer-background-color: #FFFFCC; border: 1px none #000000&quot;><IMG SRC=&quot;Image/titlebar.gif&quot; WIDTH=&quot;737&quot; HEIGHT=&quot;102&quot;></DIV>


</BODY>
</HTML>
 
<BODY BGCOLOR=&quot;#FFFFCC&quot; onLoad=&quot;initVars()&quot;>
no funtion &quot;initVars()&quot; exists....

<!--Hide javascript from browser-->
This line doesn't do what you think it does...


Var userName = document.frmcontact.textfield1.value;
javascript is case sensitive --> Var != var (the V should be lowercase)

There may be other problems - but these hit me first


Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
<INPUT TYPE=&quot;submit&quot; NAME=&quot;Submit&quot; VALUE=&quot;Submit&quot;>

needs to be

<INPUT TYPE=&quot;submit&quot; NAME=&quot;Submit&quot; VALUE=&quot;Submit&quot; onclick=&quot;checkEmail()&quot;>

Mark
 
I'm not very good at this but it doesn't look like you're invoking the function checkEmail()

I deleted onload=&quot;initvars()&quot; from the BODY tag.

I added onmouseover=&quot;checkEmail()&quot; to the SUBMIT button and it seemed to work.
 
anyideas,

That's already covered here...

<FORM action=&quot; method=&quot;POST&quot; NAME=&quot;frmcontact&quot; onSubmit=&quot;return checkEmail();&quot;>


Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
stormbind

ah ha.. just to quick... for my own good as mwolf00 gladly points out!!

darn too!!

mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top