CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Posts
    438

    Question How do YOU validate data?

    Sorry I know I've been asking loads of questions on this site, but I've just got a job doing web development and this is my first commercial experience.

    I've been using regular expressions to validate form fields but I'm finding my code is getting too long to deal with. 4+ lines of code for each form field is excessive so I was wondering what the best way of doing form validation is? Is it best to make my own function with regualar expressions in to calculate things out, or should I use something else?

  2. #2
    Join Date
    Oct 2006
    Location
    slavia
    Posts
    42

    Re: How do YOU validate data?

    the validation process is different for every type of field of course.
    if the differences among all fields that u want to validate is very significant, then of course the way u treat the validation is different that will result in longer lines of codes
    i think, there are many of validation samples in javascript and php

    imho.... it'd be better if u let us know sample of fields that u want to validate, and what kind of validation is needed for those fields ...

    such as :
    field Name cannot contain digit
    field username must be more than 6 char...
    for all fields cannot be empty

    CMIIW ...


  3. #3
    Join Date
    May 2002
    Posts
    10,943

    Re: How do YOU validate data?

    For all validation that you do, you will have to make it object specific. There is no standard way of validating. For example. One field might be an email. In that case, you will need to look for @ and a period after that and letters after the period. If its a phone number, you will allow only numbers (sometimes parenthesis and a hyphen). Each field will be formatted differently, so how you validate all depends on the type of field that it is.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured