Field Validation with MatchText

Eric Chatonet eric.chatonet at sosmartsoftware.com
Fri Jan 11 03:44:56 EST 2008


Hi dcp,

Answer a bit off topic :-)
 From an ergonomic point of view it might be not desirable to display  
modal error dialogs every time any entry does not comply with what is  
expected.
Very boring for the user to whom you say: 'You are not very bright...  
Click the OK button to agree with this and do it again!'
Instead you can work upstream by preventing the user to enter a wrong  
value i.e. by allowing him to type an expected char and not any  
another one.
No beep, no alert: if the char is not right nothing happens and  
that's all: it acts as a simple non intrusive reminder.

To achieve this, "#020 How to master users data in entry boxes"  
tutorial might help you:
This stack shows you how to allow the user to type the data you  
expect according to a format in an entry box field.
Five examples are provided from a simple ZIP code to custom  
sophisticated formats.
You will access this tutorial through "Tutorials Picker" a free  
plugin that interfaces with the So Smart Software website in order to  
display all available tutorials stacks directly from the web.
You will find it by going to http://www.sosmartsoftware.com/.
Revolution/Plugins or Tutorials section.

Best regards from Paris,
Eric Chatonet.

PS. You can add a tooltip to the entry box (or better: a contextual  
help area somewhere on the card) that will remind the user about  
expected formats.

Le 10 janv. 08 à 23:54, dcpbarrington a écrit :

> My data validation is failing in a strange way.  If I enter the  
> correct
> value, the validation comes back TRUE and everything is ok, but if  
> I put in
> a BAD value, the data validation returns FALSE and displays the  
> correct
> error message.  WORKS AS EXPECTED, BUT  The application returns the  
> user to
> the data entery field with the text selected.  I then enter the  
> data in the
> correct format and from then on the validation always returns  
> FALSE.  I must
> be using something incorrectly or there is a bug.  Here is what I  
> have in RR
> V2.8.1
>
> I have a Postal Code data entry field that I have added the following
> validation:
>
> on closeField
>   put me into tPostalCode
>   if CheckPostalCode(tPostalCode)= false then
>     answer error "Format of postal code is incorrect: ##### or  
> #####-####"
>     select the text of me
>     exit closeField
>     end if
> end closeField
>
> CheckPostalCode is a Stack Script
>
> --|
> function CheckPostalCode tCodeToCheck
> put "^(\d5(( |-)\d4)?)"  into tRegExp
> answer information "Code = " &tCodeToCheck && " Exp = " &tRegExp
> return matchText(tCodeToCheck, tRegExp)
> end CheckPostalCode
>
> I have added a debug statement and the data the I have entered is  
> being sent
> to the matchText function and the regular express is as I defined.   
> Once the
> error starts I'm unable to leave the data entry field without the  
> error
> condition and must close the card to get out of the loop.  Any  
> ideas would
> be appreciated.
>
> dcp

----------------------------------------------------------------
Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: eric.chatonet at sosmartsoftware.com/
----------------------------------------------------------------




More information about the use-livecode mailing list