Converting newValue to uppercase
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 10:35 AM
I have a Service Catalog item with an input field.
I have Client script that I run onChange of this input field that checks input value. In order to avoid case mis-types, I am trying to convert the input value into uppercase and then checking only the uppercase of the value:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var val = newValue.toUppercase(); // I have also tried: var val = newValue.toString().toUppercase();
if (val == 'MYTEST'){
// do something here
alert(val);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 10:54 AM - edited 03-07-2025 10:55 AM
Hi @MWright1
If you try the below code, it will give you all the characters in uppercase in your CS
var str = newValue.toUpperCase();
alert(str);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 09:03 PM
you are using wrong method name -> correct method is toUpperCase()
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var val = newValue.toUpperCase(); // Correct method name
if (val == 'MYTEST') {
// do something here
alert(val);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader