Add special characters to a numeric field

Hi,

I would like to add a special character in a numeric field. Is this possible?

In my organisation, we have a 8 digit assignment number but in some cases we have a hyphen next to the number.

Examples:
12345678
1234567-9

How do I enforce that only these values are entered in a field and not any other values?

Many thanks in advance!

Dear @Qman,
It would be best to use a regular text field instead as Number fields only accept numeric values. You can specify acceptable patterns for the text fields, more on that here - Single-line Text field — Public web forms

1 Like

Hi,

I think the pattern window is only available for PlumSail Online. I only have access to the program so I would need to code the Regex. Can you provide me with the code? That would be most helpful. My programming skills are not the best!

Dear @Qman,
We can help you with programming, but we need to know which version you're working with. Can you send me a screenshot from the editor, where the field is selected and the version number is visible?

Dear @Qman,
My bad, you're actually right - this is only available for common fields. What you can do - add SharePoint field to the form and hide it using Style property: display:none;

Then you can add a Common Single-line Text field with a pattern that you need, e.g. : ^([0-9]-?){8}$

Or you can add a Common Masked Input field with a mask that you need, for example : ########

More on that here - Masked Input field — Public web forms

Which you can then use to populate SharePoint field, the code would look like this:

fd.spRendered(function(){
  //update common field on form load
  fd.field('MaskedInput1').value = fd.field('Title').value;
  
  //update sharepoint field on common field change
  fd.field('MaskedInput1').$on('change',function(value){
    fd.field('Title').value = value;
  });
});

Field names are given only as examples, use the correct ones for you.

Hi @mnikitina, thanks for the reply.

So the code above that you have provided will connect a common field in Plumsail to a SharePoint list?

Dear @Qman,
Yes, it will - it will copy the value with JavaScript and save it inside of a SharePoint field, and then retrieve the data from this SharePoint field, and set it inside of the common field on load.

SharePoint field will actually do the storing, and it will be hidden from a user.

Right okay, you mentioned that I need to hide the field. That doesn't make a lot of sense to me. I want to see the assignment number field in my form.

Dear @Qman,
The SharePoint field will only do the storing, so you don't want users to be able to see and edit it - instead, they would use the Common field that you place, and it would automatically copy its value inside of the hidden field.

This is how it would look like if you don't hide the SharePoint field:
hO2fiMVZfO

In this case, it would be best to hide Title field so the process is working behind the scene.

1 Like

Hi @Nikita_Kurguzov,

thanks for your reply! May I ask, what Mask did you use for the above video?

Dear @Qman,
Nothing special, I've just used: ########
# can be replaced by a digit, or + / - signs

Great! Thanks @Nikita_Kurguzov!

I also wanted to ask, is there a way to make this field more dynamic?

In my organisation, an assignment number must be 8 digits BUT there are some people who have extra assignments.

Scenario:

Person 1: 12345678
Person 2: 12345678-12

If Person 1 fills out the Masked Input field with their number, I don't want any hyphen to appear.
If Person 2 fills out the Masked Input field with their number, I want a hyphen to appear automatically.

Right now, my Masked Input field shows the hyphen which may confuse the user as they'll think they need a number after the hyphen/dash.

Here is an image:

image

Thank you so much for your help!

Dear @Qman,
You can change field's mask dynamically with JavaScript, you just need to make sure that you check for user type 1 or 2, and then modify the mask accordingly - Masked Input field — Public web forms

Hi @Nikita_Kurguzov

Unfortunately that hasn't worked.

I put in 8 digits and I can still see the Hyphen/dash symbol. Please see below:

image

Dear @Qman,
You need to set specific mask based on the user, I don't know what condition you plan to check, but it would look something like this:

fd.spRendered(function(){
    if(_spPageContextInfo.userDisplayName == 'John Smith'){
      fd.field('Field1').mask = '00000000';
    }
    else{
      fd.field('Field1').mask = "00000000-00"
    }
});
1 Like

Perfect! Thanks a lot! :slight_smile:

Dear @Qman,
Nothing is impossible, but it would require much more code than the solution provided. It's not supported out of the box.

Of course, if you're interested in adding new features to SharePoint fields, we can always offer paid support to add new properties to fields. Contact us with the requirements at support@plumsail.com to get an evaluation.

1 Like