I'm having a bit of a problem with my coding for the following page. i'm working on a project that requires me to write a "Regular Expression" for an email address and also,a regular expression that gives a popup when all fields arent entered saying " Please complete all fields" and a popup that says "Information received successfully" when everything is entered correctly.
If anyone knows how I can code this, and can help me today/tomorrow with this it would be greatly appreciated.
Thanks
btw, the email address needs to be the last field right above the submit and cancel buttons.
P.S. i placed the email field in there only to show where it needs to go and how it needs to be laid out. im not aware using this in its present form will work for a Regular Expression.
Regular Expressions
Regular Expressions
-
FlyingMonkey
- Regular Member
- Posts: 109
- Joined: Sat May 20, 2000 12:00 am
- Location: trailer park in the bushes
example form w/ required fields:
study this and you should be able to figure it out.
<script>
function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements
if (tempobj.name.substring(0,8)=="required"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("* You must enter all required info *")
return false
}
else
return true
}
</script>
<FORM NAME="mail_form" ACTION="mailto
erson@domain.com?Subject=Publishing Problem" METHOD="POST" ENCTYPE="text/plain" onSubmit="return checkrequired(this)">
<table border="0" width="480" cellspacing="0">
<tr><td align="right"><FONT CLASS=Verdana-11pxn>Name * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredName"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>My Purchases Email * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredMy Purchases Email"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>My Purchases Password * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredMy Purchases Password"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>Host FTP Address * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredFTP Address"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>Host's FTP FAQ's Page * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredHost FAQ's Page"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>FTP Username * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredFTP Username"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>FTP Password * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredFTP Password"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>Your Website Address </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="Website URL"></td></tr>
<tr><td align="center" colspan="2"><FONT CLASS=Verdana-11pxn>Below: FTP Tool Test Results* AND description of your issue.*
(<i>Optional: Include Traceroute Results</i>)</font></td></tr>
<tr><td align="center" colspan="2"><TEXTAREA NAME="requiredTest Results" cols="44" rows="8"></textarea></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="Send"></td></tr></table></form>
study this and you should be able to figure it out.
<script>
function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements
if (tempobj.name.substring(0,8)=="required"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("* You must enter all required info *")
return false
}
else
return true
}
</script>
<FORM NAME="mail_form" ACTION="mailto
<table border="0" width="480" cellspacing="0">
<tr><td align="right"><FONT CLASS=Verdana-11pxn>Name * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredName"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>My Purchases Email * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredMy Purchases Email"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>My Purchases Password * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredMy Purchases Password"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>Host FTP Address * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredFTP Address"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>Host's FTP FAQ's Page * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredHost FAQ's Page"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>FTP Username * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredFTP Username"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>FTP Password * </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="requiredFTP Password"></td></tr>
<tr><td align="right"><FONT CLASS=Verdana-11pxn>Your Website Address </font></td><td align="left">
<INPUT TYPE = "text" size="28" NAME="Website URL"></td></tr>
<tr><td align="center" colspan="2"><FONT CLASS=Verdana-11pxn>Below: FTP Tool Test Results* AND description of your issue.*
(<i>Optional: Include Traceroute Results</i>)</font></td></tr>
<tr><td align="center" colspan="2"><TEXTAREA NAME="requiredTest Results" cols="44" rows="8"></textarea></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="Send"></td></tr></table></form>
No one has any right to force data on you
and command you to believe it or else.
If it is not true for you, it isn't true.
LRH
and command you to believe it or else.
If it is not true for you, it isn't true.
LRH