cancel
Showing results for 
Search instead for 
Did you mean: 

Validation on the form using constraints

former_member188396
Participant
0 Kudos

Hi,

I have form with some fields and validations attached to it.

I have added the constraints to validate the data. Everything works fine and it gives the error if wrong data or in wrong format.

Unfortunately, it shows error on the optional field as well because I have added the constraint to it to validate data in the correct format. I have phone field and I need data in the format xxx-xxx-xxxx.

For this, i have added below constraint.

<Input id="iCommNum" maxLength="12" value="{path: 'AddAddress>/Number1', formatter: '.formatter.formatTelephone', type:'sap.ui.model.type.String' , constraints : { search : '^\\d{3}-\\d{3}-\\d{4}' }}" width="10em" type="Tel" placeholder="XXX-XXX-XXXX"/>

With this, even value is blank, it throws an error. I want to show error only if user enters something and not in the correct format. If no values provided, no error should be shown.

Let me know how that can be achieved.

-Bhavik

View Entire Topic
Joseph_BERTHE
Active Contributor
0 Kudos

Hello,

Have you try the UI Control sap.m.MaskInput ?

Regards