validation - Validating User Input for Letters -
I am trying to validate a user input recently so that only letters of the alphabet are accepted, I How do I do this? I know how the user input is valid for most things, but this one line of code for the letters is actually bothering me.
You can check the contents of a field with this function: You can also check already: This method is a bit verbose > in your field
function String Return Match Text (Valid, String, "^ [a-zA-Z] + $") is valid
^ [a-zA-Z] + $ < / Code> is a regular expression
^
indicates the beginning of a string, the brackets determine the same character and a set of expression characters within the bracket. +
means that all the following characters will be equal to the preceding (set) character (s). The end of the string indicates that in other words, according to this expression, one should be one of all the characters and it will include z or A and it will include Z. matchText ()
is a LiveCode function, which checks that the string in the first parameter matches the regular expression in the second parameter. Call the valid ()
function anywhere on the card or stack level and call it in a rawKeyUp
handler:
at rawKeyUp If not valid (my text) then beep answered "Sorry, this is wrong" end if end raw KYE
Of You can insert the
handler. mail text
function in the
Comments
Post a Comment