Skip to main content
Participant
January 7, 2011
Answered

cfinput validation or mask?

  • January 7, 2011
  • 3 replies
  • 1728 views

Let me preface this with I am a newbie when it comes to ColdFusion.

I have a cfinput textbox that I want enforce the the entry of a six digit number or the word 'prospect', but nothing else.

How can I go about doing this?

Thanks

EDIT: Server is CF8

    This topic has been closed for replies.
    Correct answer Adam Cameron.

    Yes Adam, but he wants either one of these , a six digit number or a word PROSPECT, in this regEx will work??

    Im sorry if i m wrong.


    I wouldn't've suggested it if it wouldn't work ;-)

    prospect|(?:\d{6})


    --

    Adam

    3 replies

    Inspiring
    January 10, 2011

    Hi,

    If you want to restrict the user to enter only 6 characters, you could use " maxLength " attribute.

    You could also use a Javascript function in this attribute "onValidate"; first get the first character, if its a number, check for the length (6) and loop through it for the length and check for each character is a number, or if its a word, check for PROSPECT.

    Inspiring
    January 10, 2011

    Yikes!  That'd be a lot of unnecessary work.

    One can just use the native <cfinput> functionality to perform a regex validation for that.

    --

    Adam

    Inspiring
    January 10, 2011

    Yes Adam, but he wants either one of these , a six digit number or a word PROSPECT, in this regEx will work??

    Im sorry if i m wrong.

    Inspiring
    January 7, 2011

    Definetly not a mask.  Probably custom js.

    Inspiring
    January 7, 2011

    You could use the regular expression validation feature of CFINPUT.