Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
As the field's custom Validation script enter this:
event.value = event.value.toLowerCase();
Copy link to clipboard
Copied
Sorry, I might have read it too quickly... Do you expect there to be other (non-numeric) characters in the field?
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
It's triggered from a button outside of the field that also triggers a number of other things. It works.