1. #1
    Sencha Premium Member
    Join Date
    Dec 2007
    Posts
    7
    Vote Rating
    0
    schorse is on a distinguished road

      0  

    Default Validation bug in TextField

    Validation bug in TextField


    We use a lot of validators on TextField.
    In the beta release they are only called when the TextInputCell lose ther focus.
    This makes a Validator pretty useless.

    We have attached a patch to fix this.
    Attached Files

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,732
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Try textField.setAutoValidate(true) when using the field to make it validate after each key. By default fields do not validate until blur - why tell the user they are already wrong when they haven't finished yet?

    Or am I missing something?

  3. #3
    Sencha Premium Member
    Join Date
    Dec 2007
    Posts
    7
    Vote Rating
    0
    schorse is on a distinguished road

      0  

    Default Example

    Example


    To clarify the problem with the current TextInputCell i have create a small example app.
    Attached Files

  4. #4
    Sencha User PhiLho's Avatar
    Join Date
    Nov 2011
    Location
    Near Paris, France
    Posts
    140
    Vote Rating
    1
    PhiLho is on a distinguished road

      0  

    Default


    Quote Originally Posted by Colin Alworth View Post
    why tell the user they are already wrong when they haven't finished yet?
    When the validation is not intrusive (just a hint), I find the technique useful. For example, if the user types letters in a numbers-only text field, it is better to warn early. For example, in my (desktop) text editor, sometime I hit Ctrl+G (go to line number) instead of Ctrl+F (find) and I am happy not to type a whole string before being warned it is useless...

  5. #5
    Sencha User WesleyMoy's Avatar
    Join Date
    Oct 2009
    Location
    Redwood City, California
    Posts
    402
    Vote Rating
    2
    WesleyMoy is on a distinguished road

      0  

    Default


    I've filed a ticket against the team for http://www.sencha.com/forum/showthre...g-in-TextField. If we make any changes, I'll update that thread.
    Last edited by WesleyMoy; 17 Feb 2012 at 1:47 PM. Reason: Clarify

  6. #6
    Sencha Premium Member
    Join Date
    Dec 2007
    Posts
    7
    Vote Rating
    0
    schorse is on a distinguished road

      0  

    Default


    Works now as expected in beta 4, thanks

  7. #7
    Ext GWT Premium Member
    Join Date
    Apr 2010
    Posts
    17
    Vote Rating
    0
    4723 is on a distinguished road

      0  

    Default


    Do you think also about asynchronous validating process ? After blur field shall lock (pending state) and start ex. remote value test (via rpc). After receiving the response callbck should continue to validate.

  8. #8
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,732
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Two possibilities for validating. If you are validating an entire form, editing an object with GWT's Editor drivers, use the EditorDriver.setConstraintViolations method, which will pass the errors on down to the fields to show the issue (this can be seen at http://www.sencha.com/examples-dev/#...factorybinding by leaving the name field blank and clicking save). You can use JSR 303 validations on your server, or you can build some class which implements the ConstraintViolation interface. As a third option, GWT provides the static method SimpleViolation.simpleViolations with the easier to implement SimpleViolation abstract class. If you are already using the Editor framework, this is almost certainly the correct choice.

    The second possibility is to call one of the Field methods to assign a error manually. The first of these is Field.forceInvalid method: this can be called at any time to force a field to be invalid. As the javadoc describes, this will not be cleared as a result of the user entering more data. The second is Field.markInvalid, which may be cleared as soon as validation occurs again. In either case, I would suggest attaching a handler on the ValueChangeEvent to start validation instead of implementing the Validator interface, which is meant to be used synchronously.