Expand my Community achievements bar.

SOLVED

RegExp email compare

Avatar

Level 5

This code is flagging all legimate email addresses regardless of what I enter upon the "Exit" event of the field. I only wish the code to flag those email addresses that don't end in @metalworks.com. Does anyone spot the error or what I am missing? Thanks.

var r = new RegExp("^[a-z0-9_\\-\\.] + \\@metalworks.com");

var result = r.test(form1.Page1.Document.OnethruTen.OneThruFour.Four.ResponsibleEmail.rawValue);

if (result == true) // If it fits the general form,

{}           

else

{

form1.Page1.Document.OnethruTen.OneThruFour.Four.ResponsibleEmail.rawValue = "";

xfa.host.messageBox("You have entered an invalid Email address. \nAll email addresses must end in '@metalworks.com'.","Email Verification", 4, 0)

}

;  

1 Accepted Solution

Avatar

Correct answer by
Level 8

Make sure your Regular expression string doesn't have any spaces in it.

Also, for your if statement, you can change your condition to if (result==false) that way you don't need an empty execution block {}.

Kyle

View solution in original post

2 Replies

Avatar

Correct answer by
Level 8

Make sure your Regular expression string doesn't have any spaces in it.

Also, for your if statement, you can change your condition to if (result==false) that way you don't need an empty execution block {}.

Kyle

Avatar

Level 5

Spaces in RegExp were the culprit. Thank you.