Hybrid View

  1. #1
    Ext User
    Join Date
    Oct 2008
    Posts
    19
    Vote Rating
    0
    bboyle18 is on a distinguished road

      0  

    Default GXT Form Validation

    GXT Form Validation


    Hi,

    Just wondering if there are any plans to build in form validation to GXT?

    Thanks

    Brian

  2. #2
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    3
    gslender is on a distinguished road

      0  

    Default


    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,
    grant

  3. #3
    Ext User
    Join Date
    Oct 2008
    Posts
    19
    Vote Rating
    0
    bboyle18 is on a distinguished road

      0  

    Default


    Great. Thanks for your reply

  4. #4
    Ext User
    Join Date
    Jul 2009
    Posts
    7
    Vote Rating
    0
    retha_pasalli is on a distinguished road

      0  

    Default


    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

  5. #5
    Sencha User
    Join Date
    Aug 2008
    Posts
    226
    Vote Rating
    2
    TheBuzzer is on a distinguished road

      1  

    Default


    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;
            }
    
        };

  6. #6
    Ext User
    Join Date
    Jul 2009
    Posts
    7
    Vote Rating
    0
    retha_pasalli is on a distinguished road

      0  

    Default


    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);