How to auto-capitalise / uppercase text field?

I wish to have a field where after users type in text, when clicking away or the next field, it auto-uppercases the text.

I tried the below but had no luck:

fd.field('JobNumber').$on('change', function(value) {
fd.field('JobNumber').value = value.toUpperCase()
})

If I auto-uppercase the text, will the uppercase version get pulled through to the worksheet as well, or will it still remain lower case.

Thanks,

Hello @Viorel ,
try this :slight_smile:

fd.spRendered(() => {
  fd.field("Title").$on("change", (val) => {
    const upper = val.toUpperCase();
    fd.field("Title").value = upper;
  });
});

1 Like

I would've thought that would work, but doesn't seem to.

I've changed 'Title' to our own field name, of course.

Hello @Viorel
Well, the letters are still lowercase? Which data of field are you using? Single line of text? Is it a SharePoint field or Controls from Plumsail?
image

If you are using control, you should use:

// Instead of fd.field use line below
fd.control("TextField")

Or check developer console if there are any different errors that would block this line of code. If often happens when some code before does not execute and your line of code with "uppercasing" is ignored.

Solved it, I changed

fd.spRendered

to

fd.rendered

Then it worked.

Thank you for the help @StepanS!

1 Like

Well do you use Public Forms? I thought you use Plumsail Forms for Onprem or Sharepoint Online. I am glad you solved it out :slight_smile:

It was a public form, not SharePoint.

Thank you for the help!

You're a star :star_struck:

@StepanS How would I just capitalise the first letter in every word?
Essentially for a person's name.

I'm going to use this for a different form too :blush:

This did the trick:

fd.rendered(() => {
fd.field("Name").$on("change", (val) => {
const upper = val.replace(/\b\w/g, (char) => char.toUpperCase());
fd.field("Name").value = upper;
});
});

@Viorel Is this a question or have you already solved it? :slight_smile:

1 Like

Just solved now, sorry for confusion.

Added it above for others if they need this in the future.

1 Like