[thelist] Form Validation Bug

Gary Koh gktbone at yahoo.com
Tue Jul 9 23:10:01 CDT 2002


Hello, I have read up an article cooncerning smart
wed-based forms written by mwarden at
http://www.evolt.org/article/Writing_Smart_Web_based_Forms/17/10199/index.html.

I have tried to create validation form after reading
the article. Upon submitting the form, the input
fields will be proccessed and any incorrectly entered
text fields will be highlighted red. Correct fields
will be left in black. However, theres a bug in my
coding which always highlight all the fields
regardless if they have been correctly or incorrectly
filled.

Dim sid, spw, sname, sadd, stel, smail, sstatus
sid = trim(request.form("uid"))
spw = trim(request.form("upw"))
sstatus = trim(request.form("select"))
sname = trim(request.form("uname"))
sadd = trim(request.form("uadd"))
stel = trim(request.form("utel"))
smail = trim(request.form("umail"))

if sid="" then bGoodid=false else bGoodid=true
if spw="" then bGoodpw=false else bGoodpw=true
if sstatus="" then bGoodstatus=false else
bGoodstatus=true
if sname="" then bGoodname=false else bGoodname=true
if sadd="" then bGoodadd=false else bGoodadd=true
if stel="" then bGoodtel=false else bGoodtel=true
if smail="" then bGoodmail=false else bGoodmail=true

bGoodPost = (bGoodid and bGoodpw and bGoodstatus and
bGoodname and bGoodadd and bGoodtel and bGoodmail)

if bGoodPost then
"All data that was entered by user will be stored
within the database"

else
displayerror()
End If
End Sub

%>
<%
Sub displayerror()
%>


<form name="form3" form method="POST"
autocomplete="off">
<input type="hidden" name="action2" value="Save Form
Data2" />
<tr>
<td><font

	<%if not bGoodid then response.write "
color=""#ff0000"""%>

>UserId</font>
<input
	type="text"
	name="uid"
	value="<%Response.Write request.form("uid")%>"
></td>
<br>


The code seems logical to me. If bGoodid=false then
text to be highlighted, if bGoodid=true, then it
remains the same.

I hope you guys can help me out with this one. Thanks.
Gary

__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com



More information about the thelist mailing list