client script for strong password validation using Regex.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 10:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 10:41 PM
Hi Arjuna,
There must be some requirement i.e. what is strong password? combination of numbers and digits etc
check this link and sample script below
Sample script below either have it as onChange or onSubmit
//The password will take character in between 8-15 and will must consist at least one small character. one capital character, one digit and any special character among @#$%^&+=.
function onSubmit() {
var inputtext = g_form.getValue('Password'); // give your field/variable name here
var param = /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).{8,15}/;
if(!inputtext.match(param))
{
alert('Please Provide Correct Password');
return false;
}
else
return true;
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2020 11:08 AM
Hi Arjuna ,
Please go through below thread once:
Please mark it as helpful if it helps.
Thanks,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2020 11:24 AM
Hi,
Please use the following client script:
type:onsubmit
script:
function onSubmit() {
var pswd = g_form.getValue('passwordfield'); // give your field/variable name here
var param = ^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,});
if(!pswd.match(param))
{
alert('Kindly enter a strong password.');
return false;
}
else
return true;
}
---------------
Details of regex expressions being used:
^ The password string will start this way
(?=.*[a-z]) The string must contain at least 1 lowercase alphabetical character
(?=.*[A-Z]) The string must contain at least 1 uppercase alphabetical character
(?=.*[0-9]) The string must contain at least 1 numeric character
(?=.[!@#\$%\^&]) The string must contain at least one special character, but we are escaping reserved RegEx characters to avoid conflict
(?=.{8,}) The string must be eight characters or longer
Regards,
Munender