Hi David,

johnl wrote:
> Does anyone have an example of how to use a validator with textfield? 
> Specifically I'm interested in validating floating point numbers.

The validation system is quite neat and attaches a callback function to 
a textfield to perform the check. For instance, you could use parseFloat 
as the basis of a routine to check the value.


Another approach is to use a Regular Expression:

  var validator_cb =
    qx.ui.form.TextField.createRegExpValidator(new RegExp('^\\d+'));

(I know you said you wanted to check for floating point numbers, but 
wasn't sure where you needed 'e' notion etc. There will be many REs on 
the web)

In both cases you then associate the function with the text field.

  field.setValidator(validator_cb);

Later you call isValid on the text field to validate it. What I then do 
is something like

  field.setBackgroundColor("#FFc4c4");

if is doesn't pass.



Hopefully that should get you a bit further forwards,


Regards,

Nick

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to