Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to validate the text box input?

    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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,729
    Thanks
    202
    Thanked 2,507 Times in 2,485 Posts
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •