Announcement

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

    Masking and Validations

    SmartClient Version: v11.0p_2017-02-11/PowerEdition Deployment (built 2017-02-11)
    I have a form bound to datasource.

    I have set the masking on phone number field and want the masked data to be saved in DB.

    ((TextItem) form.getField("phone").setMask("(###) ###-####");
    ((TextItem) form.getField("phone").setMaskSaveLiterals(true);

    Now before saving i need to check that the user enters the numbers in above format and should contain 10 digits. I tried
    MaskValidator phnvalidator= new MaskValidator();
    phnvalidator.setMask("(###) ###-####");
    form.getField("phone").setValidators(phnvalidator);
    But still the validation does not happen. Even if i enter 33, it gets saved


    #2
    See docs: the "mask" provided for a MaskValidator is expected to be a regular expression.

    If you're not aware of what a regular expression is, please Google it.

    Comment


      #3
      Thanks. It works with regex.

      Comment

      Working...
      X