- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2019 09:48 PM
Hi,
I have a form in that i want to do Email Id validation it should be abc123@gmail.com
please help me on the same functionality.
Regards,
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2019 10:53 PM
hi
check this code in background script
var emailAddr='abc123@gmail.com';
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailAddr))
{
gs.print('yes')
}
else{
gs.print("You have entered an invalid email address!")
}
Thanks,
Rahul Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2019 09:56 PM
Hi,
You can write an on change client script on Email ID field with the following script in it.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}else if(oldValue != newValue){
var reg = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if (!reg.test(newValue)){
alert('You should enter a valid email address');
g_form.clearValue('u_email_id'); //Replace email id field name
}
}
}
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2019 10:12 PM
Hi Veera,
For this u can first create a script include and call this script include on server side using business rule. I have tried this practically and it works.
1) Create script include
// Use JavaScript coercion to guarantee emailStr is a string
emailStr = emailStr + '';
// Compare emailStr against the allowed syntax as specified in the regular expression
// If emailStr has allowed syntax, return true, else return false
if(emailStr.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)){
return true;
}
else {
return false;
}
}
-
Name: Email Address Syntax ValidateTable: NeedIt [x_<your_company_code>_needit_needit]Active: Selected (checked)Advanced: Selected (checked)
-
Switch to the When to run section and continue configuring the Business Rule:
When: BeforeInsert: Selected (checked)Update: Selected (checked) -
Click the Submit button.
-
Switch to the Advanced section.
var isEmail = validateEmailAddress(current.u_requested_for_email);
// If isEmail is false (email address syntax is not valid) do not save
// the record. Write an error message to the screen.
if(isEmail == false){
gs.addErrorMessage(current.u_requested_for_email + " is not a valid email address. You must provide a valid email address.");
current.setAbortAction(true);
}
And also refer below link,
If u find my answer helpful. Kindly mark it as correct or helpful.
Thanks,
Priti

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2019 10:53 PM
hi
check this code in background script
var emailAddr='abc123@gmail.com';
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailAddr))
{
gs.print('yes')
}
else{
gs.print("You have entered an invalid email address!")
}
Thanks,
Rahul Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2019 11:08 PM
Hi Veera,
Do you want to validate the email format like 3 chars and 3 digits followed by @gmail.com? or do you want to validate whether the entered email is abc123@gmail.com or not? What is your requirement?