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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validation

Status
Not open for further replies.

PhoenixDown

Programmer
Jul 2, 2001
279
0
0
CA
I posted this before but it didn't fix my problem.

Code:
if ($vars_gen{'Field2Data'} eq "email") {
if (($in{'Field2'} eq "") || ($in{'Field2'} !~ /\w+@\w+\.\w+/)) {
	&GBStandardHTML(&quot;You have entered an invalid email address. Your email address must contain an ampersand (@), a period (.), and at least one letter or number.&quot;, &quot;<meta http-equiv=\&quot;refresh\&quot; content=\&quot;$vars_gen{'Secs'};URL=$vars_gen{'CGIURL'}gb.cgi?action=add_entry\&quot;>&quot;);
exit;
}
}

if ($vars_gen{'Field2Data'} eq &quot;url&quot;) {
if (($in{'Field2'} eq &quot;&quot;) || ($in{'Field2'} !~ /http:\/\/.*?\.\w+/)) {
	&GBStandardHTML(&quot;You have entered an invalid URL for the $vars_gen{'Field2Name'} field. Your URL must include the [URL unfurl="true"]http://.&quot;);[/URL]
exit;
}
}

Now, this code checks if a valid email is entered and if http:// is there. What I want it to do is to not display any errors if someone didn't enter anything in the field. If they did, the script will check to see if it's a valid email address, or if http:// is there. Can someone fix that for me. Thank you. - Go there!
 
do a little changes on the if's.
that is, currently, you have (on the http:// part)
this:

if ($vars_gen{'Field2Data'} eq &quot;url&quot;) {
if (($in{'Field2'} eq &quot;&quot;) || ($in{'Field2'} !~ /http...

turn this into:

if ($vars_gen{'Field2Data'} eq &quot;url&quot;
and $in{'Field2'} ne &quot;&quot;) {
if (($in{'Field2'} !~ /http...


--
pkiller
 
I tried:

Code:
if ($vars_gen{'Field2Data'} eq &quot;url&quot; and $in{'Field2'} ne &quot;&quot;) {
if (($in{'Field2'} !~ /http:\/\/.*?\.\w+/)) {
	&GBStandardHTML(&quot;You have entered an invalid URL for the $vars_gen{'Field2Name'} field. Your URL must include the [URL unfurl="true"]http://.&quot;);[/URL]
exit;
}
}

And it didn't work. - Go there!
 
hmm... can't help you more than this :(

The new &quot;if&quot; only enters on GBStandardHTML() if
$in{'Field2'} isn't empty. It seems that was what
you have pretented, but I don't know enough on the
inner structure of your code...

cya

--
pkiller


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top