Expand my Community achievements bar.

Urgent Pls... Textfield validation

Avatar

Level 2

Hi All,

In a textfield its should accept two conditions i.e.,

1) It should accept 10 digits or

2) In a field it should accept two chars and 5 digits. or than that its should pop up an alert.

I have tried setting patterns and worte the script in exit event:


if(this.rawValue == this.formattedValue)
{
xfa.host.setFocus(this.name);
}

But the setFocus is going again and again.

Patterns: text{AA99999}|text{9999999999}

Please help.

Thanks in advance

Regards,

Apurva

2 Replies

Avatar

Level 9

Hi Apurva,

You need regular expression for this. Remove all the validations of the text field first i.e display,edit,validation,data.

In the exit event of the field put the following script.

var vPattern = /^([a-zA-Z]{2}[0-9]{5})$|^([0-9]{10})$/;
var result = vPattern.test(this.rawValue);
if (result == false)
{
    xfa.host.setFocus(this.name);
}

Thanks,

Bibhu.

Avatar

Level 2

Hi Bibhu,

Thank you so much for ur help.

Regards,

Apurva