- Create a new Form.
- Add a Text Field to it.
- Go into the Object –> Value window of the Text field
- Choose –> validation Script Message (error)
- Create a message saying that the mail address is wrong.
- Go into the Script Editor (CTRL-SHIFT-F5).
- Put in this little script as a JavaSscipt (run at Client)
var r = new RegExp();
r.compile("^[a-z0-9_-.]+@[a-z0-9_-.]+.[a-z]{2,3}$","i");
var result = r.test(this.rawValue);
if (result == true)
true;
else
false;
Add a button that validates your form like the Email Submit Button.
Done...
// report error if there is an invalid email address when the field is not empty.
if (! eMailValidate(event.value) && event.value != "") {
event.rc = false;
app.alert({
cMsg: "Invalid email address - Please try again",
cTitle: "Acme Testing Service",
nIcon: 0,
nType: 1
});
} // end if validation test
Or only run the script if the field is not empty:
if(event.value != "") {
if (! eMailValidate(event.value)) {
event.rc = false;
app.alert({
cMsg: "Invalid email address - Please try again",
cTitle: "Acme Testing Service",
nIcon: 0,
nType: 1
});
} // end if validation test
} // end non-null field
No comments:
Post a Comment