Dynamic Pattern for Common Text Field

Dear Community,

at the moment I'm creating a SharePoint Form where the Postcode inputs should be checked on the pattern. I want to use a normal common Text Field instead of the Masked Input Field.

My question is, if it is possible to set a dynamic value as pattern for the normal Text Field like it is possible for the Masked Input here: image
And if it is possible, could you provide the code for me?

Thank you for your help :slight_smile:

Hello @Jan,

The mask property is not available for SharePoint fields.

Why don't you want to use Masked Input? You can set up the mask for the common field and save the value to SharePoint field. For instance, using this code on Edit form:

fd.spRendered(function() {
    //set the common field with the previously selected value
    fd.field('MaskedInput1').value = fd.field('SharePointField').value;

    //fill SharePoint field with the common field value
    fd.field('MaskedInput1').$on('change', function() {
        fd.field('SharePointField').value = fd.field("MaskedInput1").value;

You can find the example of using common fields in Populate common Drop Down field with values from any SharePoint list article.

Hello @mnikitina,

thank you for your answer. I realized that you might have missunterstood me so I'm trying to tell my issue in a better way.

I wanted to use the pattern of the common text field to use different RegEx codes depending on the country selection. For example when a person selectes Great Britain in the list of the countries than the input should be possible for all of the following patterns:


which is possible with this RegEx code: "^$|([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9][A-Za-z]?))))\s?[0-9][A-Za-z]{2})$"

But when I want to use a RegEx code it is only possible in the pattern property of an common field.
Is there anyway to set the property value depending on the selected value or to use an RegEx code in the mask property of an Masked Input Field?

Hello @Jan,

Now its clear. Thank you!

There is no way to change the pattern property of the commun field dynamically. But you can use custom field validator that works for both common and SharePoint fields:

//clear validator
fd.field('Title').validators.length = 0;
//add new validator
    name: 'MyCustomValidator',
    error: 'iThis field must contain a valid e-mail address.',
    validate: function(value) {
      //var value = fd.field('test').value;
      var regex = /^[^@\s][email protected][^@\s]+\.[^@\s]+$/;
      return regex.test(value)
1 Like