br*********@yahoo.com wrote:
I have a form field on an ASP page and was wondering if I can require
the number that is entered to begin with a 0 or a 2. If the number
starts with anything else, the user is notified to update the number
correctly (Your [FormField] must begin with a 0 or a 2, Please update
your entry). Any code snip of this would be great.
Since this is an ASP group, I will provide an ASP answer:
<%
dim val, msg, visible
val=request.form("FormField")
if len(val) > 0 then
if left(val,1) = "0" or left(val,1) = "2" then
visible="none"
'process the data
else
msg="Your [FormField] must begin with a 0 or a 2, Please update" & _
" your entry"
visible="block"
end if
end if
%>
<html><body><form method="post">
Enter FormField: <input type="text" name="FormField"
value=" <%= server.htmlencode(val) %>">
<div style="display:<%=visible%>"><%=msg%></div>
<INPUT type="submit" value="Submit">
</form></BODY></HTML>
If you want a client-side answer, post to the
microsoft.public.scripting.jscript group.
HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.