Regular Expressions

General software, Operating Systems, and Programming discussion.
Everything from software questions, OSes, simple HTML to scripting languages, Perl, PHP, Python, MySQL, VB, C++ etc.
Post Reply
User avatar
Roody
SG VIP
Posts: 30735
Joined: Sun Nov 19, 2000 12:00 am
Location: East Tennessee

Regular Expressions

Post 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
FlyingMonkey
Regular Member
Posts: 109
Joined: Sat May 20, 2000 12:00 am
Location: trailer park in the bushes

Post 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?
User avatar
TonyT
SG VIP
Posts: 10356
Joined: Fri Jan 28, 2000 12:00 am
Location: Fairfax, VA

Post 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>

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
User avatar
Roody
SG VIP
Posts: 30735
Joined: Sun Nov 19, 2000 12:00 am
Location: East Tennessee

Post 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.
User avatar
Roody
SG VIP
Posts: 30735
Joined: Sun Nov 19, 2000 12:00 am
Location: East Tennessee

Post 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.
cyberskye
Senior Member
Posts: 4717
Joined: Wed Jan 10, 2001 12:00 am
Location: DC

Post by cyberskye »

had to dig back to school days :)

try this http://py-howto.sourceforge.net/regex/regex.html
anything is possible - nothing is free

:wth:
Blisster wrote:It *would* be brokeback bay if I in fact went and hung out with Skye and co (did I mention he is teh hotness?)
:wth:
User avatar
Roody
SG VIP
Posts: 30735
Joined: Sun Nov 19, 2000 12:00 am
Location: East Tennessee

Post by Roody »

thanks cyberskye. ill take a look at that :)
User avatar
Roody
SG VIP
Posts: 30735
Joined: Sun Nov 19, 2000 12:00 am
Location: East Tennessee

Post 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.
Post Reply