Hybrid View
-
10 Oct 2008 2:58 PM #1
GXT Form Validation
GXT Form Validation
Hi,
Just wondering if there are any plans to build in form validation to GXT?
Thanks
Brian
-
10 Oct 2008 3:08 PM #2
Brian,
FormPanel does have an isValid method that checks validation of all contained fields - with that you can have standard and custom validation for all fields.
cheers,
grantGXT JavaDocs: http://extjs.com/deploy/gxtdocs/
GXT FAQ & Wiki: http://extjs.com/learn/Learn_About_the_Ext_GWT_Library
Buy the Book on GXT: http://www.apress.com/book/view/9781430219408
Follow me on Twitter: http://twitter.com/gslender
-
10 Oct 2008 4:26 PM #3
-
15 Jul 2009 6:00 PM #4
Hi..
If I want to make an email validation in a textfield, how can I do that?
In GWT-Ext we can use :
TextField email = new TextField("Email", "email");
email.setVtype(VType.EMAIL);
How to do that in GXT? Is there any tutorial?
Thx for any replies..
Regards,
Retha
-
16 Jul 2009 7:15 AM #5
Code:TextField<String> emailaddress = new TextField(); emailaddress.setValidator(validator); private Validator validator = new Validator() { @Override public String validate(Field<?> field, String value) { if (field == emailaddress) { if (!emailaddress.getValue().toLowerCase().matches("(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])")) { return "Bad E-mail Address"; } } return null; } };
-
16 Jul 2009 5:32 PM #6
Thx TheBuzzer...
I also find the answer :
TextField<String> email = new TextField();
email.setRegex(".+@.+\\.[a-z]+");
email.getMessages().setRegexText("Bad email address!!");
email.setAutoValidate(true);


Reply With Quote