Text Wild Card

DKinsley

02-09-2015

I want to write a script to verify the user entered their company email address correctly. The only part of the email address I can verify is the last section (@companyname.com), Is there a text wild card that I can use that represents and amount of text so I can verify the last section of the address, like *:

If(emailaddress.rawValue !== *@companyname.com){

xfa.host.msgbox("Last part of your email address is not correct");

}

Accepted Solutions (1)

Accepted Solutions (1)

radzmar

MVP

03-09-2015

Here you go


var str = Textfield1.rawValue;



if (!str.match(/^([a-zA-Z0-9\-\_\.]+)@(domain1|domain2).com$/gm)) {


  xfa.host.messageBox("The E-Mail-Address in not correct …");


}


Answers (3)

Answers (3)

DKinsley

03-09-2015

radzmar,

Your script works great but I have two company domains that I have to compair to what the user enters. In other words they have to enter either myname@domain1.com or myname@domain2.com. If it is neither of these then the error message pops-up. I tried to modify your script to accomdate this but cannot get it to work.



var str = this.rawValue;

if ((!str.match(/^([a-zA-Z0-9\-\_\.]+)@yourdomain.com$/gm))||(!str.match(/^([a-zA-Z0-9\-\_\.]+)@yf.com$/gm))) {

  xfa.host.messageBox("The E-Mail-Address in not correct …");

  }

radzmar

MVP

02-09-2015

Hi,

you can use a regular expression to test the email-addresses.


var str = Textfield1.rawValue;



if (!str.match(/^([a-zA-Z0-9\-\_\.]+)@yourdomain.com$/gm)) {


  xfa.host.messageBox("The E-Mail-Address in not correct …");


} else {


    // Script to execute otherwise …


}


Hope this helps.