needexpert
asked on
Validation btn not working now?
I have read my code until I am blue in the face. I am doing a client side validation. I changed a couple of things but now I got something out of wake with my curly braces I think. Can someone please look at the code and tell me what I am doing wrong. The check() function is where the problem is and the code was nicely formated until I pasted it here. Thanks for a fast reply.
<HTML>
<HEAD>
<TITLE>form</TITLE>
<SCRIPT language = "Javascript">
<!--
btnvalup = new Image; btnvalup.src = "images/BtnValidateGoldUp. jpg";
btnvaldown = new Image; btnvaldown.src = "images/BtnValidateGoldDow n.jpg";
function MouseOver(BtnName)
{
if (BtnName=="btnValidate")
{
document.btnValidate.src = btnvaldown.src;
}
if (BtnName=="btnSubmit")
{
document.btnSubmit.src = btnsubdown.src;
}
}
function MouseOut(BtnName)
{
if (BtnName=="btnValidate")
{
document.btnValidate.src = btnvalup.src;
}
if (BtnName=="btnSubmit")
{
document.btnSubmit.src = btnsubup.src;
}
}
function check()
{
var count=0;
var msg="";
for(i=0;i<=7;i++)
{
if(document.frmRegistratio n.elements [i].name== "regname")
{
if(document.frmRegistratio n.elements [i].value. length<1)
{
count=1;
msg=msg+"\nName may not be left blank.";
document.frmRegistration.e lements[i] .focus();
}
if(count==0)
{
if(document.frmRegistratio n.elements [i].value. length<6)
{
count=1;
msg=msg+"\nName must have a minimum of 6 characters.";
document.frmRegistration.e lements[i] .value="";
document.frmRegistration.e lements[i] .focus();
}
}
if(document.frmRegistratio n.elements [i].value. length >25)
{
count=1;
msg=msg+"\nName cannot exceed 25 characters in length";
document.frmRegistration.e lements[i] .value="";
document.frmRegistration.e lements[i] .focus();
}
}
if(document.frmRegistratio n.elements [i].name== "email")
{
emailchar=document.frmRegi stration.e mail.value .split("@" )
if(emailchar.length>1)
{
index=emailchar[1].indexOf (".")
if(index == -1)
{
document.frmRegistration.e lements[i] .focus()
return false
}
else
{
return true
}
}
else
{
document.frmRegistration.e lements[i] .focus()
return false
}
}
if(document.frmRegistratio n.elements [i].name== "login")
{
if(document.frmRegistratio n.elements [i].value. length<1)
{
count=1;
msg=msg+"\nLogin Name may not be left blank.";
document.frmRegistration.e lements[i] .focus();
}
if(count==0)
{
if(document.frmRegistratio n.elements [i].value. length<6)
{
count=1;
msg=msg+"\nLogin Name must have a minimum of 6 characters.";
document.frmRegistration.e lements[i] .value="";
document.frmRegistration.e lements[i] .focus();
}
}
if(document.frmRegistratio n.elements [i].value. length >25)
{
count=1;
msg=msg+"\nLogin Name cannot exceed 25 characters in length";
document.frmRegistration.e lements[i] .value="";
document.frmRegistration.e lements[i] .focus();
}
}
if(document.frmRegistratio n.elements [i].name== "password" )
{
if(document.frmRegistratio n.elements [i].value. length<1)
{
count=1;
msg=msg+"\nPassword may not be left blank.";
document.frmRegistration.e lements[i] .focus();
}
if(count==0)
{
if(document.frmRegistratio n.elements [i].value. length<6)
{
count=1;
msg=msg+"\nPassword must have a minimum of 6 characters.";
document.frmRegistration.e lements[i] .value="";
document.frmRegistration.e lements[i] .focus();
}
}
if(document.frmRegistratio n.elements [i].value. length >25)
{
count=1;
msg=msg+"\nPassword cannot exceed 25 characters in length";
document.frmRegistration.e lements[i] .value="";
document.frmRegistration.e lements[i] .focus();
}
}
else if((i>=7) && (count==0))
{
return(true);
}
}
for(i=0;i<=7;i++)
{
if(document.frmRegistratio n.elements [i].value= ="")
{
alert("PLEASE CORRECT THE FOLLOWING ERROR(S)\n "+msg);
document.frmRegistration.e lements[i] .focus();
return(false);
}
}
}
-->
</SCRIPT>
</HEAD>
<BODY ONLOAD=document.frmregistr ation.regn ame.focus( ) BGCOLOR = "#000066" TEXT = "#CC9900">
<CENTER>
<TABLE BORDER="1" CELLPADDING="0" WIDTH="55%">
<TR>
<TD>
<IMG SRC="images/HeadingRegistr ationForm. jpg" NAME="heading" ALT="Registration Form" WIDTH="564" HEIGHT="63">
</TD>
</TR>
<TR>
<TD>
<p align="center">
<IMG SRC="images/LineGoldBlue.j pg" NAME="line" ALT="Gold Line" WIDTH="464" HEIGHT="6">
</p>
</TD>
</TR>
</TABLE>
<center>
<FORM METHOD="post" ACTION="addDisplay.asp" NAME="frmRegistration">
<TABLE BORDER="1" CELLPADDING="3" WIDTH="427" height="279">
<center>
<TR>
<TD width="216" height="25"><font arial size="4">
Name:
</FONT></TD>
<TD width="180" colspan="4" height="25">
<INPUT TYPE="text" NAME="regname" SIZE="35">
</TD>
<TD width="89" colspan="2" height="25">
</TD>
</TR>
<tr>
<TD width="216" height="25"><FONT Arial SIZE="4">
E-mail:
</FONT></TD>
<TD width="180" colspan="4" height="25">
<INPUT TYPE="text" NAME="email" SIZE="35">
</TD>
<TD width="89" colspan="2" height="25">
</TD>
</tr>
<TR>
<TD width="216" height="18"></TD>
<TD width="269" colspan="6" height="18">
</TD>
</TR>
<TR>
<TD width="216" height="25"><font arial size="4">
Login Name:
</FONT></TD>
<TD width="1" height="25">
<INPUT TYPE="text" NAME="login" SIZE="25">
</TD>
<TD width="0" colspan="2" height="25">
</TD>
<TD width="269" colspan="3" height="25">
</TD>
</TR>
<TR>
<TD width="216" height="41"><FONT Arial SIZE="4">
Password:
</FONT></TD>
<TD width="126" height="41">
<INPUT TYPE="password" NAME="password" SIZE="25">
</TD>
<TD width="111" rowspan="3" height="41" colspan="4">
<p align="right" style="line-height: 100%"><font arial size="3"><b>
Remember password?</b></font>
<FONT Arial SIZE="4">
</FONT>
</TD>
<TD width="32" rowspan="3" height="41">
<INPUT TYPE="checkbox" NAME="checkbox" VALUE="yes" CHECKED>
</TD>
</TR>
<tr>
<TD width="216" height="18"></TD>
<TD width="269" colspan="6" height="18"></TD>
</tr>
<tr>
<TD width="216" height="23"><FONT Arial SIZE="4">
Title:
</FONT></TD>
<TD width="180" colspan="4" height="23"><FONT Arial SIZE="4">
<INPUT TYPE="radio" NAME="title" VALUE="Mr" CHECKED >Mr.
<INPUT TYPE="radio" NAME="title" VALUE="Ms">Ms.
<INPUT TYPE="radio" NAME="title" VALUE="Mrs">Mrs.
</FONT></TD>
<TD width="89" colspan="2" height="23"></TD>
</tr>
<TR>
<TD width="216" height="25"><FONT Arial SIZE="4">
Area of interest?
</FONT></TD>
<TD width="90" colspan="2" height="25">
<SELECT SIZE="1" NAME="area">
<OPTION SELECTED VALUE="wd">Web Design</OPTION>
<OPTION VALUE="wp">Web Programming</OPTION>
<OPTION VALUE="wm">Web Marketing</OPTION>
<OPTION VALUE="wa">Web Administration</OPTION>
</SELECT>
</TD>
<TD width="90" colspan="2" height="25">
</TD>
<TD width="89" colspan="2" height="25">
</TD>
</TR>
<!-- <TR HEIGHT="60" VALIGN="BOTTOM">-->
<TD WIDTH="216" ALIGN="LEFT" height="18">
<INPUT TYPE=image SRC="images/BtnValidateGol dUp.jpg" NAME="I10" ALT="Validate" ONCLICK="return check()" WIDTH="112" HEIGHT="23" onmouseover="MouseOver('bt nvalidate' )" onmouseout="MouseOut('btnv alidate')" >
</TD>
<TD WIDTH="759" ALIGN="RIGHT" colspan="6" height="18">
<INPUT TYPE=image SRC="images/BtnSubmitGoldU p.jpg" NAME="I11" ALT="Submit" " WIDTH="112" HEIGHT="23" onmouseover="MouseOver('bt nsubmit')" onmouseout="MouseOut('btns ubmit')">
</TD>
</center>
</TABLE>
</FORM>
</center>
<font size = -1>All graphics used on this site were generated by using: <BR><a href="http://www.yahoo.com" style="color:
rgb(0,255,0)"><font color="FF00CC">http://www.flamingtext.com</font></a>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>form</TITLE>
<SCRIPT language = "Javascript">
<!--
btnvalup = new Image; btnvalup.src = "images/BtnValidateGoldUp.
btnvaldown = new Image; btnvaldown.src = "images/BtnValidateGoldDow
function MouseOver(BtnName)
{
if (BtnName=="btnValidate")
{
document.btnValidate.src = btnvaldown.src;
}
if (BtnName=="btnSubmit")
{
document.btnSubmit.src = btnsubdown.src;
}
}
function MouseOut(BtnName)
{
if (BtnName=="btnValidate")
{
document.btnValidate.src = btnvalup.src;
}
if (BtnName=="btnSubmit")
{
document.btnSubmit.src = btnsubup.src;
}
}
function check()
{
var count=0;
var msg="";
for(i=0;i<=7;i++)
{
if(document.frmRegistratio
{
if(document.frmRegistratio
{
count=1;
msg=msg+"\nName may not be left blank.";
document.frmRegistration.e
}
if(count==0)
{
if(document.frmRegistratio
{
count=1;
msg=msg+"\nName must have a minimum of 6 characters.";
document.frmRegistration.e
document.frmRegistration.e
}
}
if(document.frmRegistratio
{
count=1;
msg=msg+"\nName cannot exceed 25 characters in length";
document.frmRegistration.e
document.frmRegistration.e
}
}
if(document.frmRegistratio
{
emailchar=document.frmRegi
if(emailchar.length>1)
{
index=emailchar[1].indexOf
if(index == -1)
{
document.frmRegistration.e
return false
}
else
{
return true
}
}
else
{
document.frmRegistration.e
return false
}
}
if(document.frmRegistratio
{
if(document.frmRegistratio
{
count=1;
msg=msg+"\nLogin Name may not be left blank.";
document.frmRegistration.e
}
if(count==0)
{
if(document.frmRegistratio
{
count=1;
msg=msg+"\nLogin Name must have a minimum of 6 characters.";
document.frmRegistration.e
document.frmRegistration.e
}
}
if(document.frmRegistratio
{
count=1;
msg=msg+"\nLogin Name cannot exceed 25 characters in length";
document.frmRegistration.e
document.frmRegistration.e
}
}
if(document.frmRegistratio
{
if(document.frmRegistratio
{
count=1;
msg=msg+"\nPassword may not be left blank.";
document.frmRegistration.e
}
if(count==0)
{
if(document.frmRegistratio
{
count=1;
msg=msg+"\nPassword must have a minimum of 6 characters.";
document.frmRegistration.e
document.frmRegistration.e
}
}
if(document.frmRegistratio
{
count=1;
msg=msg+"\nPassword cannot exceed 25 characters in length";
document.frmRegistration.e
document.frmRegistration.e
}
}
else if((i>=7) && (count==0))
{
return(true);
}
}
for(i=0;i<=7;i++)
{
if(document.frmRegistratio
{
alert("PLEASE CORRECT THE FOLLOWING ERROR(S)\n "+msg);
document.frmRegistration.e
return(false);
}
}
}
-->
</SCRIPT>
</HEAD>
<BODY ONLOAD=document.frmregistr
<CENTER>
<TABLE BORDER="1" CELLPADDING="0" WIDTH="55%">
<TR>
<TD>
<IMG SRC="images/HeadingRegistr
</TD>
</TR>
<TR>
<TD>
<p align="center">
<IMG SRC="images/LineGoldBlue.j
</p>
</TD>
</TR>
</TABLE>
<center>
<FORM METHOD="post" ACTION="addDisplay.asp" NAME="frmRegistration">
<TABLE BORDER="1" CELLPADDING="3" WIDTH="427" height="279">
<center>
<TR>
<TD width="216" height="25"><font arial size="4">
Name:
</FONT></TD>
<TD width="180" colspan="4" height="25">
<INPUT TYPE="text" NAME="regname" SIZE="35">
</TD>
<TD width="89" colspan="2" height="25">
</TD>
</TR>
<tr>
<TD width="216" height="25"><FONT Arial SIZE="4">
E-mail:
</FONT></TD>
<TD width="180" colspan="4" height="25">
<INPUT TYPE="text" NAME="email" SIZE="35">
</TD>
<TD width="89" colspan="2" height="25">
</TD>
</tr>
<TR>
<TD width="216" height="18"></TD>
<TD width="269" colspan="6" height="18">
</TD>
</TR>
<TR>
<TD width="216" height="25"><font arial size="4">
Login Name:
</FONT></TD>
<TD width="1" height="25">
<INPUT TYPE="text" NAME="login" SIZE="25">
</TD>
<TD width="0" colspan="2" height="25">
</TD>
<TD width="269" colspan="3" height="25">
</TD>
</TR>
<TR>
<TD width="216" height="41"><FONT Arial SIZE="4">
Password:
</FONT></TD>
<TD width="126" height="41">
<INPUT TYPE="password" NAME="password" SIZE="25">
</TD>
<TD width="111" rowspan="3" height="41" colspan="4">
<p align="right" style="line-height: 100%"><font arial size="3"><b>
Remember password?</b></font>
<FONT Arial SIZE="4">
</FONT>
</TD>
<TD width="32" rowspan="3" height="41">
<INPUT TYPE="checkbox" NAME="checkbox" VALUE="yes" CHECKED>
</TD>
</TR>
<tr>
<TD width="216" height="18"></TD>
<TD width="269" colspan="6" height="18"></TD>
</tr>
<tr>
<TD width="216" height="23"><FONT Arial SIZE="4">
Title:
</FONT></TD>
<TD width="180" colspan="4" height="23"><FONT Arial SIZE="4">
<INPUT TYPE="radio" NAME="title" VALUE="Mr" CHECKED >Mr.
<INPUT TYPE="radio" NAME="title" VALUE="Ms">Ms.
<INPUT TYPE="radio" NAME="title" VALUE="Mrs">Mrs.
</FONT></TD>
<TD width="89" colspan="2" height="23"></TD>
</tr>
<TR>
<TD width="216" height="25"><FONT Arial SIZE="4">
Area of interest?
</FONT></TD>
<TD width="90" colspan="2" height="25">
<SELECT SIZE="1" NAME="area">
<OPTION SELECTED VALUE="wd">Web Design</OPTION>
<OPTION VALUE="wp">Web Programming</OPTION>
<OPTION VALUE="wm">Web Marketing</OPTION>
<OPTION VALUE="wa">Web Administration</OPTION>
</SELECT>
</TD>
<TD width="90" colspan="2" height="25">
</TD>
<TD width="89" colspan="2" height="25">
</TD>
</TR>
<!-- <TR HEIGHT="60" VALIGN="BOTTOM">-->
<TD WIDTH="216" ALIGN="LEFT" height="18">
<INPUT TYPE=image SRC="images/BtnValidateGol
</TD>
<TD WIDTH="759" ALIGN="RIGHT" colspan="6" height="18">
<INPUT TYPE=image SRC="images/BtnSubmitGoldU
</TD>
</center>
</TABLE>
</FORM>
</center>
<font size = -1>All graphics used on this site were generated by using: <BR><a href="http://www.yahoo.com" style="color:
rgb(0,255,0)"><font color="FF00CC">http://www.flamingtext.com</font></a>
</BODY>
</HTML>
Now let me try and find the js problem...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Let me try it. I knew it was something so stupid... !!!! Thanks. Get right back to you.
Still not working - but not getting any errors...
ASKER
It seems to be the Validate button on the left that isn't working and I took the ONCLICK out of the Submit button and that is where the extra " came from but if I put it back in then it still doesn't validate using the check() function.
ASKER
I block out the email section which was the last thing I added and the validation works so it is in the email section of the check() function. I will keep looking.
Just doing the same thing...
ASKER
Seems that I got this code to work except for I can put a @ and . together so I guess I would use the split here
if(document.frmRegistratio n.elements [i].name== "email")
{
if(document.frmRegistratio n.elements [i].value. length>1)
{
if(document.frmRegistratio n.elements [i].value. indexOf('. ') < 0 ||
document.frmRegistration.e lements[i] .value.ind exOf('@') >
document.frmRegistration.e lements[i] .value.ind exOf('.'))
{
count=1;
msg=msg+"\nE-mail address is invalid.";
document.frmRegistration.e lements[i] .value="";
document.frmRegistration.e lements[i] .focus();
}
}
if(count==0)
{
if(document.frmRegistratio n.elements [i].value. length<7)
{
count=1;
msg=msg+"\nA valid E-mail address must have a minimum of 7 characters.";
document.frmRegistration.e lements[i] .value="";
document.frmRegistration.e lements[i] .focus();
}
}
if(document.frmRegistratio n.elements [i].value. length >25)
{
count=1;
msg=msg+"\nE-mail address cannot exceed 25 characters in length";
document.frmRegistration.e lements[i] .value="";
document.frmRegistration.e lements[i] .focus();
}
}
if(document.frmRegistratio
{
if(document.frmRegistratio
{
if(document.frmRegistratio
document.frmRegistration.e
document.frmRegistration.e
{
count=1;
msg=msg+"\nE-mail address is invalid.";
document.frmRegistration.e
document.frmRegistration.e
}
}
if(count==0)
{
if(document.frmRegistratio
{
count=1;
msg=msg+"\nA valid E-mail address must have a minimum of 7 characters.";
document.frmRegistration.e
document.frmRegistration.e
}
}
if(document.frmRegistratio
{
count=1;
msg=msg+"\nE-mail address cannot exceed 25 characters in length";
document.frmRegistration.e
document.frmRegistration.e
}
}
ASKER
How can I check to make sure > 1 between '@' and '.'?
Let me post a pointer to this Q from the Javascript section...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or
...
regEx= /^\w+([\.-]?\w+)*@\w+([\.- ]?)\w*(\.\ w{2,4})+$/
and in your validation routine
if(!regEx.test(textboxEmai l.value)){
alert("Invalid email format. Please enter a valid email.\n");
return false;
}
...
regEx= /^\w+([\.-]?\w+)*@\w+([\.-
and in your validation routine
if(!regEx.test(textboxEmai
alert("Invalid email format. Please enter a valid email.\n");
return false;
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\. -]?\w+)*(\ .\w{2,3})+ $/.test(my Form.email Addr.value )){
return (true)
}
if (/^\w+([\.-]?\w+)*@\w+([\.
return (true)
}
PS. A ".info" address would fail this validation!
BFN,
fp.
BFN,
fp.
Suggest this instead:
function checkEmail(myForm)
{
return (/^\w+([\.-]?\w+)*@\w+([\. -]?\w+)*(\ .\w{2,4})+ $/.test(my Form.email Addr.value ));
}
function checkEmail(myForm)
{
return (/^\w+([\.-]?\w+)*@\w+([\.
}
not mine
i would be glad to redo this whole form validation for you, but i need to know why you
are doing all of this looping?
I really do not see any need for a loop, unless all fields are required, but if they are
then we can make this code shorter, neater, easier to maintain.
Please let me know what exactly you wanna do
are doing all of this looping?
I really do not see any need for a loop, unless all fields are required, but if they are
then we can make this code shorter, neater, easier to maintain.
Please let me know what exactly you wanna do
already done Jay
function check(){
var count=0;
var msg="";
var strErr="";
regExName=/^[A-Z][A-Z '-]{4,23}[A-Z]$/gi;
regExLog=/^[A-Z][A-Z '-]{4,23}[A-Z]$/gi;
regExPass=/^[A-Z][A-Z '-]{4,23}[A-Z]$/gi;
regExEmail= /^\w+([\.-]?\w+)*@\w+([\.- ]?)\w*(\.\ w{2,4})+$/ ;
if(!regExName.test(documen t.getEleme ntById('re gname').va lue)){
if(!strErr){
strErr='regname';
}
msg=msg+"\nInvalid format for Name.\n Name must be between 6 and 25 characters in length.";
}
if(!regExEmail.test(docume nt.getElem entById('e mail').val ue)){
if(!strErr){
strErr='email';
}
msg=msg+"\nInvalid format for Email.\n Please enter a valid email";
}
if(!regExLog.test(document .getElemen tById('log in').value )){
if(!strErr){
strErr='login';
}
msg=msg+"\nInvalid format for Log In ID.\n Log In ID must be between 6 and 25 characters in length.";
}
if(!regExPass.test(documen t.getEleme ntById('pa ssword').v alue)){
if(!strErr){
strErr='password';
}
msg=msg+"\nInvalid format for Password.\n Password must be between 6 and 25 characters in length.";
}
if(msg){
alert(msg);
document.getElementById(st rErr).focu s();
}
return (msg ? false : true);
}
-->
function check(){
var count=0;
var msg="";
var strErr="";
regExName=/^[A-Z][A-Z '-]{4,23}[A-Z]$/gi;
regExLog=/^[A-Z][A-Z '-]{4,23}[A-Z]$/gi;
regExPass=/^[A-Z][A-Z '-]{4,23}[A-Z]$/gi;
regExEmail= /^\w+([\.-]?\w+)*@\w+([\.-
if(!regExName.test(documen
if(!strErr){
strErr='regname';
}
msg=msg+"\nInvalid format for Name.\n Name must be between 6 and 25 characters in length.";
}
if(!regExEmail.test(docume
if(!strErr){
strErr='email';
}
msg=msg+"\nInvalid format for Email.\n Please enter a valid email";
}
if(!regExLog.test(document
if(!strErr){
strErr='login';
}
msg=msg+"\nInvalid format for Log In ID.\n Log In ID must be between 6 and 25 characters in length.";
}
if(!regExPass.test(documen
if(!strErr){
strErr='password';
}
msg=msg+"\nInvalid format for Password.\n Password must be between 6 and 25 characters in length.";
}
if(msg){
alert(msg);
document.getElementById(st
}
return (msg ? false : true);
}
-->
Not really jester
yours will only work in browsers that support document.getElementById
you should use document.forms[0]
also to put focus to the first element, i would (since its a textbox) use document.forms[0].elements [0].focus( );
also use <form name="form1" .......... onsubmit="return check();">
and do NOT use <input type="button"...onclick="c heck();">
use <input type="submit" name="btnSubmit" value="Submit">
yours will only work in browsers that support document.getElementById
you should use document.forms[0]
also to put focus to the first element, i would (since its a textbox) use document.forms[0].elements
also use <form name="form1" .......... onsubmit="return check();">
and do NOT use <input type="button"...onclick="c
use <input type="submit" name="btnSubmit" value="Submit">
>>yours will only work in browsers that support document.getElementById
oops, thought this was ns 4+ but it is 6... my fault
>>also to put focus to the first element, i would (since its a textbox) use document.forms[0].elements [0].focus( );
should be part of the onload, not the check function
>>also use <form name="form1" .......... onsubmit="return check();">
>><input type="submit" name="btnSubmit" value="Submit">
always do
>>and do NOT use <input type="button"...onclick="c heck();">
never
;-)
oops, thought this was ns 4+ but it is 6... my fault
>>also to put focus to the first element, i would (since its a textbox) use document.forms[0].elements
should be part of the onload, not the check function
>>also use <form name="form1" .......... onsubmit="return check();">
>><input type="submit" name="btnSubmit" value="Submit">
always do
>>and do NOT use <input type="button"...onclick="c
never
;-)
ok here it is ns4+ and ie5+ compatible
<script>
function check(){
var count=0;
var msg="";
var strErr="";
regExName=/^[A-Z][A-Z '-]{4,23}[A-Z]$/gi;
regExLog=/^[A-Z][A-Z '-]{4,23}[A-Z]$/gi;
regExPass=/^[A-Z][A-Z '-]{4,23}[A-Z]$/gi;
regExEmail= /^\w+([\.-]?\w+)*@\w+([\.- ]?)\w*(\.\ w{2,4})+$/ ;
if(!regExName.test(documen t.forms[0] .elements[ 'regname'] .value)){
if(!strErr){
strErr='regname';
}
msg=msg+"\nInvalid format for Name.\n Name must be between 6 and 25 characters in length.";
}
if(!regExEmail.test(docume nt.forms[0 ].elements ['email']. value)){
if(!strErr){
strErr='email';
}
msg=msg+"\nInvalid format for Email.\n Please enter a valid email";
}
if(!regExLog.test(document .forms[0]. elements[' login'].va lue)){
if(!strErr){
strErr='login';
}
msg=msg+"\nInvalid format for Log In ID.\n Log In ID must be between 6 and 25 characters in length.";
}
if(!regExPass.test(documen t.forms[0] .elements[ 'password' ].value)){
if(!strErr){
strErr='password';
}
msg=msg+"\nInvalid format for Password.\n Password must be between 6 and 25 characters in length.";
}
if(msg){
alert(msg);
document.forms[0].elements [strErr].f ocus();
}
return (msg ? false : true);
}
-->
</script>
<script>
function check(){
var count=0;
var msg="";
var strErr="";
regExName=/^[A-Z][A-Z '-]{4,23}[A-Z]$/gi;
regExLog=/^[A-Z][A-Z '-]{4,23}[A-Z]$/gi;
regExPass=/^[A-Z][A-Z '-]{4,23}[A-Z]$/gi;
regExEmail= /^\w+([\.-]?\w+)*@\w+([\.-
if(!regExName.test(documen
if(!strErr){
strErr='regname';
}
msg=msg+"\nInvalid format for Name.\n Name must be between 6 and 25 characters in length.";
}
if(!regExEmail.test(docume
if(!strErr){
strErr='email';
}
msg=msg+"\nInvalid format for Email.\n Please enter a valid email";
}
if(!regExLog.test(document
if(!strErr){
strErr='login';
}
msg=msg+"\nInvalid format for Log In ID.\n Log In ID must be between 6 and 25 characters in length.";
}
if(!regExPass.test(documen
if(!strErr){
strErr='password';
}
msg=msg+"\nInvalid format for Password.\n Password must be between 6 and 25 characters in length.";
}
if(msg){
alert(msg);
document.forms[0].elements
}
return (msg ? false : true);
}
-->
</script>
my version of just email validation
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
function isEmail(strValue){
var objRegExp = /^([a-zA-Z0-9_\.\-])+\@(([ a-zA-Z0-9\ -])+\.)+([ a-zA-Z0-9] {2,4})+$/;
return objRegExp.test(strValue);
}
function validateForm(fObj){
var strErr = "";
var focusField = "";
if(!isEmail(fObj.email.val ue)){
strErr += "Email is in the wrong format\n";
if(focusField == "") focusField = "email";
}
if(strErr != ""){
alert("The following fields contain errors\n\n"+ strErr);
eval("fObj."+ focusField +".focus()");
return false;
}
return true;
}
// -->
</script>
</head>
<body>
<form name="form1" method="post" action="" onsubmit="return validateForm(this);">
<input type="text" name="email">
<input type="submit" name="btnSubmit" value="Submit">
</form>
</body>
</html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
function isEmail(strValue){
var objRegExp = /^([a-zA-Z0-9_\.\-])+\@(([
return objRegExp.test(strValue);
}
function validateForm(fObj){
var strErr = "";
var focusField = "";
if(!isEmail(fObj.email.val
strErr += "Email is in the wrong format\n";
if(focusField == "") focusField = "email";
}
if(strErr != ""){
alert("The following fields contain errors\n\n"+ strErr);
eval("fObj."+ focusField +".focus()");
return false;
}
return true;
}
// -->
</script>
</head>
<body>
<form name="form1" method="post" action="" onsubmit="return validateForm(this);">
<input type="text" name="email">
<input type="submit" name="btnSubmit" value="Submit">
</form>
</body>
</html>
NO POINTS TO ME
>>NO POINTS TO ME
??
why would you say that?
??
why would you say that?
The asker is going to have a hard time piecing all this together... any way we can agree on which is the best solution?
No need in them, i was just posting another way to do it, so that if anyone else searches and
finds this once its paq they will have alternitives.
finds this once its paq they will have alternitives.
let jay decide
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i added a submit button for testing purposes.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I managed to get it done without reading these posted comments, however l appreciate everyones comments and help. I will review and decide where to distribute the points and I know that I will learn from your postings.
Thanks again.
Thanks again.
np... glad i was able to help
There is no known email regex that is perfect, there are dozens and dozens of valid email forms this is one ot he better regex's
/(([^<>()[\]\\.,;:\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,}))/
/(([^<>()[\]\\.,;:\s@\"]+(
ALT="Submit" "