Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Custom validator added for DataSourceLinkField is not working

    Hi,

    I have added custom regular expression validator for link field to validate URL.

    It is not validating the field on call of FilterBuilder.validate().


    Code snippet:
    --------------
    DataSourceField dataSourceSrcField = new DataSourceLinkField(name, title);
    RegExpValidator expValidator = new RegExpValidator();
    expValidator.setExpression("^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]");
    expValidator.setValidateOnChange(true);
    dataSourceSrcField.setValidators(expValidator);

    Can anyone help with this.

    Regards,
    Cijo P

    #2
    By design, forms used for searching do not apply validation rules, because what a user enters as search criteria usually does not fit the validation rules that apply to data meant to be stored.

    It's not clear what you're up to here - it seems unlikely that you really intend to force the user to enter a complete URL before they are allowed to search? But if you wanted a rule like that, the simplest thing is to pop up a warning dialog when the search is attempted.

    Comment

    Working...
    X