- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 07:15 AM
I want to write a catalog client script on a record producer that allows only whole numbers to be typed in a variable field. I have a script written that gives an error message if a decimal point is included in what they type, but the problem with this is they can't type a number with .0 at the end, which would be a whole number.
What would be the best way to make sure they have to type in a whole number, but they can still type in .0? My current script is below. Any ideas are appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 07:55 AM
Hello ,
You can add one more AND condition to your if loop saying
if(inputValue.includes('.') && !inputValue.includes('.0'))
i tried this and it worked for me.Please try this thing and let me know and
Please don't forget to mark this helpful or accept the solution if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 07:16 AM
Hi,
image is missing
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 07:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 07:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 07:55 AM
Hello ,
You can add one more AND condition to your if loop saying
if(inputValue.includes('.') && !inputValue.includes('.0'))
i tried this and it worked for me.Please try this thing and let me know and
Please don't forget to mark this helpful or accept the solution if it helps you