regex is correct but some issue in the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 11:25 AM
Hi,
I wrote the regex for validating the email ID, but the problem is coming with respect to the code. Kindly help.
function onSubmit() {
var email_ID = g_form.getValue("email");
var testEmail = /^([a-z0-9A-Z\_\.]*)@([a-z\.]*)$/;
if (!testEmail.test(email_ID)) {
g_form.addErrorMessage("invalid email");
return false;
}
return true;
Regards
Suman P.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 11:36 AM
It would help to know what the error message is. I'm assuming you did not paste all of the code since you are missing a "}" at the end and its not really formatted well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 11:39 AM - edited 04-09-2024 11:40 AM
Hi @DrewW ,
Here is the complete script formatted. It is showing error even for proper format ones
function onSubmit() {
var email_ID = g_form.getValue("email");
var testEmail = /^([a-z0-9A-Z\_\.]*)@([a-z\.]*)$/;
if (!testEmail.test(email_ID)) {
g_form.addErrorMessage("invalid email");
return false;
}
return true;
}
Regards
Suman P.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 12:00 PM
Sounds like you need to check your RegEx like @maroon_byte is mentioning.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 12:09 PM
Hi @DrewW and @maroon_byte ,
My exact requirement is I can have as many a-z, A-Z, 0-9 before @. Then after that, it should only accept small letters.
So, I tried to update it like this. Still doesn't work.
function onSubmit() {
var email_ID = g_form.getValue("email");
var testEmail = /^([a-z0-9A-Z\_\.]*)@([a-z]*)+\.[a-z]*$/;
if (!testEmail.test(email_ID)) {
g_form.addErrorMessage("invalid email");
return false;
}
return true;
}
Regards
Suman P.