Expand my Community achievements bar.

SOLVED

Validate if field contains specific text

Avatar

Level 1

Hi all,

I want to make a script in my form that validate's a field for a specific word.

I have an field where users can put there e-mail adres in, but all addresses with Yahoo in it should receive a warning that those addressen can't be used.

I now have if (this.rawValue == "Yahoo")

But i need to ad a character that it doesn't matter wich text is before of after that text, if it contains yahoo the warning must come up.

how can I do this?

Greetings,

Timo

1 Accepted Solution

Avatar

Correct answer by
Level 10

Try the below. Change the language to Java Script.

var strText = TextField1.rawValue.toLowerCase();

if(strText.indexOf("yahoo",0)>0)
xfa.host.messageBox("Yahoo email addresses can not be used");

Thanks

Srini

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Try the below. Change the language to Java Script.

var strText = TextField1.rawValue.toLowerCase();

if(strText.indexOf("yahoo",0)>0)
xfa.host.messageBox("Yahoo email addresses can not be used");

Thanks

Srini