Aim
Add a new validation rule to the JavaScript function for designation so that it must consist of at least two words. (Hint: use regex.)
Steps for completion
We need to revise the JavaScript. Check the following:
Go to https://goo.gl/u8y4Ur to access the code.
//validate the designation field
if (designationValue == null || designationValue == "" )
{
document.getElementById("validationDesignation").textContent =
"Employee Designation is required - from
client side";
isValidForm = false;
}
else if (!(/^[a-z]+(?:\s[a-z]+)+$/.test(designationValue )))
{
document.getElementById(
"validationDesignation").textContent =
"Employee Designation must be at least two
words - from client side";
isValidForm = false;
}