Yes Javascript. In our instance PIN must be at least 9 digits long and numeric. There is no maximum length and we want to encourage longer PIN's. Thanks for the help!
On Mon, Feb 24, 2014 at 7:34 AM, David Landry <dlan...@byu.net> wrote: > On Mon, Feb 24, 2014 at 9:33 AM, David Landry <dlan...@byu.net> wrote: > > > There's a little bit of redundancy in there. Also, there's no length > > requirement (e.g. isPIN('') also returns true). > > > > Without adding length requirements, I'd do it like this: > > > > function isPIN(str) { > > return /^\+?(\d*)$/.test(str); > > } > > > > With a length requirement, it might look like this (if PINs must be 4 > > numbers long, {a,b} for a range from a to b length): > > > > function isPIN(str) { > > return /^\+?(\d{4})$/.test(str); > > } > > > > Ooops, missed this cruft, the \+? is redundant too. So, > > function isPIN(str) { > return /^(\d{4})$/.test(str); > } > > > --- > David Landry > > /* > PLUG: http://plug.org, #utah on irc.freenode.net > Unsubscribe: http://plug.org/mailman/options/plug > Don't fear the penguin. > */ > /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */