PDA

View Full Version : TextField does not revalidate on backspace



tork
3 Sep 2008, 11:44 AM
This example involves a text field. I don't think it's limited to a text field.

If I enter 10 characters then a % (invalid by regex) then field is marked as invalid. If I backspace then the field is still marked as invalid. If I type something or exit the field then it becomes valid again. If I backspace past the min length then the field stays marked as valid. Typing a character, assuming the result is still less than the min, causes the field to be marked as invalid.

Here's the detail of the field initialization.


this.projectNameTextField = new TextField();
this.projectNameTextField.setFieldLabel("Project Name");
this.projectNameTextField.setEmptyText("Enter name...");
this.projectNameTextField.setAllowBlank(false);
this.projectNameTextField.setAutoValidate(true);
this.projectNameTextField.setMinLength(6);
this.projectNameTextField.setMaxLength(25);
this.projectNameTextField.setRegex("[-#&(),a-zA-Z0-9][- #&(),a-zA-Z0-9]+");
String errorMessage = "Name must be 6-25 characters are alphanumerics and \"- #&(),\"";
this.projectNameTextField.getMessages().setRegexText(errorMessage);
this.projectNameTextField.getMessages().setInvalidText(errorMessage);
this.projectNameTextField.getMessages().setMinLengthText(errorMessage);
this.projectNameTextField.getMessages().setMaxLengthText(errorMessage);