- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 05:38 AM
i tried with the below regex
var regexp = /\d{6}@\d{5}/;
var idi = id.match(regexp);
in this before "@" i should be able to enter 6 characters and after "@" it should contain alpha numeric characters which should be 5 characters in length
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 06:47 AM
Hi,
I'm not sure what you mean by "where I can enter more than 6 characters before '@' and 5 characters after '@'".
So, yes, you can, but your validation in your client script would then check that against the pattern you've defined and if it doesn't match/work with it...you would clear the field and maybe give an alert to say "please enter in 'x' format".
The regex doesn't literally block someone from entering in a bunch of characters...it's the validation in the client script that would check it.
For example, go to: https://regex101.com/
And in the regular expression field at the top of the website, put: \d{6}@[a-zA-Z0-9]{5}
Then do some test strings for yourself. You'll see on the right, in the Match Information section...they aren't matches UNTIL you do 6 numbers, then a '@' and then 5 characters of letters or numbers.
So for this to then work in SN, you have to add / to front and / to back of the pattern. So it now becomes:
/\d{6}@[a-zA-Z0-9]{5}/
And then that should work.
But again, users can enter in all sorts of stuff in that field...it's the onChange client script that would check what they enter, against a pattern, and if it doesn't match....you'd clear the value and alert them to the pattern you're expecting.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 05:53 AM
Hey Prem ,
i think you are trying to validate the email here with regex but you can use below script,
if(oldValue != newValue){
g_form.hideFieldMsg('email', true);
if (!isEmailValid(newValue)) {
g_form.showFieldMsg('email', newValue + " is an invalid email, please re-enter email in correct format.",'error');
} }
Or
You can refer below threads for more,
kindly mark Correct and Helpful if applicable.
Regards,
Indrajit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 05:56 AM
Hi idrajit,
Im not trying to validate the email id its a single line text field where i need to validate the below format
before "@" i should be able to enter 6 characters (numbers) and after "@" it should contain alpha numeric characters which should be 5 characters in length

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 06:06 AM
Hi can you try:
var regexp = /\d{6}@[a-zA-Z0-9]{5}/;
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 06:15 AM
hi allen,
I need to type only 6 characters before @ and 5 characters after @
is it possible to restrict character limit
Before "@" 6
After "@" 5
Since in both before and after i can enter n number of numbers