Thread: Form Validation

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    7
    Rep Power
    0

    Form Validation


    Is there a way to validate a field so it has to have 4 numbers entered into it. No less and no more?
  2. #2
  3. Digitally Challenged
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    280
    Rep Power
    12
    try using the coldfusion functions Len(variable) isNumeric(variable) Find(variable, stringtofind)
    make sure the length is 4, its numeric, and it doesn't contain a . or -
    My brain cells are like a storm trooper's armor: useless
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    5
    Rep Power
    0
    Could try something like
    Code:
    <cfif LEN(TRIM(REReplaceNoCase(Form.FieldName,"[^[:digit:]]","","ALL")))>
    Value is good
    <cfelse>
    Value is bad
    </cfif>
    If "[^[:digit:]]" doesnt work on your version of CF, you can use "[^[0-9]]".

    I think "[^[0-9]]" is right

    Steve
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    3
    Rep Power
    0
    yes. and you can validate it on the client-side. use cfinput and a regular expression.

    check out: http://livedocs.macromedia.com/coldf...s/dynami38.htm

IMN logo majestic logo threadwatch logo seochat tools logo