Forum Moderators: open
i have read all the threads i could find on javascript Jumpstarts, searched for "Server Side Validation" and "Server Side Form Validation" and can not find any samples of what i need to be implementing on my site...if anyone has good direction, i would greatly appreciate at. Im using Classic ASP and submitting data to an SQL Dbase.
My form is simple and contains the following elements:
Name
Company
City
State
Phone
Email
How did you hear about us?
I am interested in:
Best time to contact me:
Then i utilize my form validation:
<script language="JavaScript" src="/includes/formValidation.js">
</script>
<script language="Javascript">
function ValidForm()
{var oForm = document._form;
oErrors= new Array();
lCount = 0;
ValidString(oForm.reqName.value,"Please fill in your Name.");
ValidString(oForm.city.value,"Please fill in your City.");
ValidString(oForm.state.value,"Please fill in your State.");
ValidString(oForm.reqAreaCode.value,"Please fill in your Area Code.");
ValidString(oForm.reqPhoneNumber.value,"Please fill in your complete Phone Number.");
ValidEmail(oForm.email.value,"Please fill in a Valid Email Address.");
if(!ShowErrors())
return true;
else
return false;
}
</script>
Depends how sophisticated you want it. I write my own functions for lengths,formats,ranges ,blanks etc, and some error message code for nice error screens but at a basic level you can just go through each form item like this:
if request.form("name")="" then
Response.write "Name is blank, go back"
response.end
end if