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

08-18-2004, 04:09 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........

<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

08-18-2004, 11:00 PM
Here you go!

Single Quotes give me a syntax error!

This is exactly what you problem is. If you wish to submit a ' as in "It's" then you need to change it to "It''s" so the database knows it's a string, and not part of the SQL command.

Don't worry, the double single quotes wont look like "It''s", it will change back when you write it to the screen.
This also goes for double quotes.

Response.Write "It''s"
Response.Write "<br>"
Response.Write """Here"""



Try it yourself!

That help?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum