Expand my Community achievements bar.

Making a field mandatory

Avatar

Former Community Member
We've designed a form for print output and want to make several fields mandatory. Selecting the option "User Entered - Required" and setting the Empty Message field does not cause any errors when the user tabs out of the field. Does that option only work for forms that are being submitted via email?



Tom
22 Replies

Avatar

Former Community Member
Hello. I'm newbie to scripting and my problem is similar to those above, but had no luck solving it. I have a field for which I want to set restriction that user has to enter 13-digit number i.e. not shorter nor longer than 13 digits.. If he enters longer or shorter number than that, the field should reset to null. I tried out many combination's, but I'm not even sure under which event to put it.. I think EXIT?

I tried something like this..



var somenr = NumericField1.value;

if (NumericField1.length == 13) {(NumericField1.value = somenr)}

else {(NumericField1 = "")};

Avatar

Level 2
Hi Iva

I think your looking for something like this, if you want to do it the script way.



//this Javascript should be placed on an exit event of a field

if (this.rawValue.length != 13 && isNaN(this.rawValue)){//Check if 13 digits and is it a numeric value

app.alert("Please enter 13 digits \nFx. 1234567890123");//alerts the user, what the error is



this.rawValue = "";//Empty the field

xfa.host.setFocus(this);//sets the focus back to the field

}



Regards

Søren Høy Nielsen