
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2019 09:02 AM
I want to be able to validate if an email address is in the correct format.
Validate this is valid email address xxxxx@xxx.xxx - if not valid email, pop "Please enter valid email address"
Is there a way to do that?
Thanks,
Karen
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2019 09:42 AM
There is an onSubmit client script included OOB with HR Service Management that has the following validation script:
function onSubmit() {
//Type appropriate comment here, and begin script below
g_form.hideErrorBox('email');
return validateEmail('email');
}
function validateEmail(field) {
var email = g_form.getValue(field);
if (!email || email.trim().length <= 0)
return true;
var re = /^(([^<>()[\]\\.,;:\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,}))$/;
if (!re.test(email)) {
g_form.showErrorBox(field, getMessage('Invalid Email'));
return false;
}
return true;
}
You should be able to reuse this in a new client script for your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2020 04:50 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2021 10:51 PM
Other than using "email type" as a field, below background script always helped me for email validation.
Use this and customize wherever you need to validate email.
// Get email address from field
var emailAddress= "123gmail.com";
//If Email address is valid, take some aciton.For example printing success message below
if (/^(([^<>()[\]\\.,;:\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,}))+$/.test(emailAddress)){
gs.info("Valid Email Address");
}
//If Email address is not valid, stop form submission or take some action
else{
gs.info("The email address format is invalid");
}
Regards
Pawan K Singh