View Full Version : How to validate the text box input?

08-18-2004, 04:07 AM
i face a problem to validate the text box input.

Now i using the javascript to validate the input, but it using the alpha, alphanumeric, numeric........

[CODE]<script language="JavaScript" type="text/javascript">
var frmvalidator = new Validator("form");
frmvalidator.addValidation("cname","maxlen=30","The Max length for name is 30");
frmvalidator.addValidation("age","maxlen=3","The Max length for age is 3");

frmvalidator.addValidation("gender","maxlen=10","The Max length for gender is 10");

frmvalidator.addValidation("race","maxlen=20","The Max length for race is 20");

frmvalidator.addValidation("hobby","maxlen=50","The Max length for hobby is 50");

frmvalidator.addValidation("interest","maxlen=50","The Max length for interest is 50");

frmvalidator.addValidation("occupation","maxlen=50","The Max length for occupation is 50");

frmvalidator.addValidation("others","maxlen=500","The Max length for others is 500");

If i type in the ' then it will not insert into the database then how? i don't want to let user to input ' in the text box.

I'm using ASP, IIS, MS SQL Server 2000, Javascript

Philip M
08-18-2004, 07:40 AM
I am slightly unclear. Are you saying that all the fields
in the form can contain only a-z A-Z and 0-9?
This is easily done with a regular expression.

But note that names may contain ' such as O'Reilly.

"The Max length for gender is 10" ... boggle, boggle!