Connecting Tech Pros Worldwide Forums | Help | Site Map

Validation Of ASP Form HELP URGENT

SpiderSwamy
Guest
 
Posts: n/a
#1: Apr 6 '06
Hi,

I know little bit about asp, I am facing a problem in Validating
the ASP Form..

Example:

Stud ID: 501242016
FirstName: Ajit
LastName: Kar

These Fileds are there in my form and I am able to Insert it into
Database.

But My problem is I am not able to restrict the Stud ID to 9 digit and
if First Name , Last Names fields are empty I want to display a message
telling please fill the Following fields.

Anyone who have any idea on this please reply me back, its urgent.

Thanks in Advance.

Regards
SpiderSwamy


Adrienne Boswell
Guest
 
Posts: n/a
#2: Apr 6 '06

re: Validation Of ASP Form HELP URGENT


Gazing into my crystal ball I observed "SpiderSwamy" <manju_016
@rediffmail.com> writing in news:1144304839.412694.294670
@z34g2000cwc.googlegroups.com:
[color=blue]
> Hi,
>
> I know little bit about asp, I am facing a problem in Validating
> the ASP Form..
>
> Example:
>
> Stud ID: 501242016
> FirstName: Ajit
> LastName: Kar
>
> These Fileds are there in my form and I am able to Insert it into
> Database.
>
> But My problem is I am not able to restrict the Stud ID to 9 digit and
> if First Name , Last Names fields are empty I want to display a message
> telling please fill the Following fields.
>
> Anyone who have any idea on this please reply me back, its urgent.
>
>[/color]

<%

if request.servervariables("Request_Method") = "POST" then

stud_id = request.form("student_id")
firstname = request.form("firstname")
lastname = request.form("lastname")

'checking for required fields
if len(stud_id) < 9 then
required = "student_id"
elseif len(firstname) = 0 then
required = "firstname"
elseif len(lastname) = 0 then
required = "lastname"
end if

if required <> "" then
message = ucase(left(required,1)) & mid(required,2) & " is
required"
else
'do processing
end if

end if
if message <> "" then
%>
<script language="JavaScript" type="text/javascript">
<!--
alert('<%=message%>');
//-->
</script>
<%
message = "<div class=" & chr(034) & "message" & chr(034) & ">
<strong>" & message & "</strong></div>"

end if
%>
<head>
<style type="text/css">
..message {font-weight:bold, color:#F00; text-align:center}
</style>
</head>
<body>
<%=message%>
<form ....

--
Adrienne Boswell
Please respond to the group so others can share
http://www.cavalcade-of-coding.info
Closed Thread