dating search jomsocial - Validating forms in coldfusion
You may indeed want to require that a value be entered, but there's an available REQUIRED attribute for the CFINPUT that will make it more clear to someone looking at your code that you're requiring an input value.
I just mention this because if you didn't think to add it (the ()?
) Finally, keep in mind that in the case of both kinds of regexps (used in the CF functions or in CFINPUT's PATTERN attribute), it's certainly acceptable to use Cold Fusion variables and other expressions to create the values to be used in the regexp.
These should not be used in the CFINPUT PATTERN since they'll be passed down to the browser and my testing suggests they're not supported in Java Script (at least they weren't in my Internet Explorer 5.5).
Some Advanced Reg Exp Tips I'd like to add a couple of comments for the benefit of more experienced regexp developers.
And despite what some may think, using CFFORM will not always cause the applet support files to load: they're loaded only when you use one of the applet-based subtags.
But CFINPUT doesn't use Java - it uses Java Script. There is still another potential issue: not all browsers support Java Script (and some users have it disabled intentionally for security concerns).
And that's a key point for the purposes of this article: the regular expressions used in CFINPUT's PATTERN attribute are Java Script regular expressions, passed verbatim to the client and interpreted on the browser.