To get started, create a form page called form.asp and copy the below code into your page:
In this case, we will make the Email, Subject, and Comments fields all required.
To validate these fields all have entries, create a page called confirm.asp and copy the below code into your page:
<% DIM strEmail, strSubject, strComments strEmail = Request.Form("Email") strSubject = Request.Form("Subject") strComments = Request.Form("Comments") IF strEmail <> "" AND strSubject <> "" AND strComments <> "" THEN
' Process the form as you like here
' For example enter form to your database or send it via email
ELSE
Response.Write "
Please click back on your browser and complete the following fields:
"IF strEmail <> "" THEN
ELSE
Response.Write "• Email
"
END IF
IF strSubject<> "" THEN
ELSE
Response.Write "• Subject
"
END IF
IF strComments <> "" THEN
ELSE
Response.Write "• Comments
"
END IF
END IF
%>
That's it in a nutshell! Now, you have a standard form with required fields. Once you understand the basics of this, you can get a lot more sophisticated and really customize your validation to meet your spcific needs.
No comments:
Post a Comment