- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 02:36 AM
Hello,
I am looking for a solution on below -
There is a field in the catalog item in which the user should only allow to enter specific text (STARTS with "ADA") and ends with a number. No special symbol is allowed.
This should be an immediate response, if the pattern does not match we should be getting an error (popup) message.
Example Text: ADARegionCountry5004
Regards,
Piyush Kumar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 11:24 PM
Hi @piyushnector ,
To make the regular expression case-insensitive, you can add the "i" flag at the end of the regular expression pattern. This will allow it to match both uppercase and lowercase letters.
Update this line var pattern = /^ADA.*\d$/; to var pattern = /^ADA.*\d$/i;
Regards,
Shravan.
Please mark as helpful and correct solution
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 08:04 AM - edited 03-06-2023 08:06 AM
Hi @piyushnector ,
Below is the code snippet for your reference.
---
In the client script please change the "u_text_field" value to the variable name on which you want to validate.
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 09:41 PM - edited 03-06-2023 09:42 PM
Thank you that works, but how can I ignore the case bcoz if user tried to fill it in lower case this will give error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 11:24 PM
Hi @piyushnector ,
To make the regular expression case-insensitive, you can add the "i" flag at the end of the regular expression pattern. This will allow it to match both uppercase and lowercase letters.
Update this line var pattern = /^ADA.*\d$/; to var pattern = /^ADA.*\d$/i;
Regards,
Shravan.
Please mark as helpful and correct solution
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2024 07:55 AM
What would var pattern look like if you needed to require the characters "-SA" at the end?
I tried the following, but it doesn't work: