I have a requirement what it meeans if i entered email filed filled with @gmail.com, @hotmail.com,@outlook.com or @yahoo.com i need to show error like "Please Provide Your Company Email ID's And Don't Use Your Personal Mail ID's". I want sloution in javascript language or sap ui5. thanks in advance.
if (input4.toString() == "@gmail.com") {
this.byId("email").setValueState("Error");
this.byId("email").setValueStateText("Please enter company Emai Id");
return false;
} else {
this.byId("email").setValueState("None");
}
You can check if the e-mail address matches your pattern using a regular expression:
var email = input4.toString();
if (/@(gmail|hotmail|outlook|yahoo)\.com$/i.test(email)) {
// error
} else {
// success
}
The i
behind the expression makes it case insensitive, so that upper-case domains will also be caught.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.