Page 1 of 1

Regular Expressions

Posted: Tue Oct 15, 2002 3:53 pm
by Roody
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

Posted: Tue Oct 15, 2002 5:07 pm
by FlyingMonkey
Are you doing this with just HTML / Javascript or do yo have some kind of server side language such as ASP or PHP processing the data?

Posted: Tue Oct 15, 2002 5:34 pm
by TonyT
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 :p 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>


Posted: Tue Oct 15, 2002 5:44 pm
by Roody
ok ill take a look at that Tony. In answer to your question this is solely html/javascript kind of thing. no server side stuff.

Posted: Tue Oct 15, 2002 7:24 pm
by Roody
tell ya what im pretty dumb when it comes to this stuff. i tried taking that code Tony and cutting and pasting to do what I need it to do and i couldnt make it happen. Trying to get this thing in a table with regular expressions.

Posted: Tue Oct 15, 2002 8:12 pm
by cyberskye
had to dig back to school days :)

try this http://py-howto.sourceforge.net/regex/regex.html

Posted: Wed Oct 16, 2002 3:23 am
by Roody
thanks cyberskye. ill take a look at that :)

Posted: Wed Oct 16, 2002 9:09 am
by Roody
well i have no clue. if anyone wants to take a stab at this for purely educational experience by all means. basically i need a table that will allow me to do what i do in my original post in here, but do it with Regular Expressions.