...

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



superman2004
08-18-2004, 05: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("age","numeric");

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

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

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

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

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

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

</script>[CODE]
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, 08: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!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum