I need help with a script to change a specific character to lowercase if it was typed in uppercase in a field. Example: 24X12X6 I need just the X's to be changed to lowercase when a button is pressed, only if a number is before and after it. Thanks!
As the field's custom Validation script enter this:
event.value = event.value.toLowerCase();
Sorry, I might have read it too quickly... Do you expect there to be other (non-numeric) characters in the field?
I actually copied and pasted my question in to ChatGPT and it gave me almost exactly what I needed.
// Get the input field value
var inputField = this.getField("Description");
var inputValue = inputField.value;
// Use a regular expression to find and replace 'X' with 'x' when surrounded by numbers
var replacedValue = inputValue.replace(/(\d)X(\d)/g, '$1x$2');
// Update the input field with the modified value
inputField.value = replacedValue;
Thank you though!
Where are you planning on using this script? Will it be on the field where the text to be converted will be placed?
If so you'll need to make some changes. The script you have will only work from outside the field.
It's triggered from a button outside of the field that also triggers a number of other things. It works.