Hello,
I would like to set a minimum and maximum amount of digits to a numeric field. I have used the following code in the change event (see below) to set the maximum, which is working for me, however I cant seem to set a minimum.
Is it possible to set a minimum, and if so, can someone please help?
var
maxLength = 6;
if(xfa.event.newText.length >maxLength)xfa.event.change = "";
Thank you,
Nik
Solved! Go to Solution.
Views
Replies
Total Likes
Here is the updated form..
https://acrobat.com/#d=CHbixTuuKW*X*uFac4c6JQ
Few things I changed..
1) Removed the Validation pattern and Validation script message.
2) I am checking the input in the Change event and Exit event for Registration and ID fields.
My code is checking to have the minimum/ maximum values for both the fields. So user cannot leave the field without entering any input.
If you want to allow the user to leave the field with out entering input, then comment out the else part in Exit event code.
Hope this helps..
Thanks
Srini
Views
Replies
Total Likes
Also, I want to do this without using 'combs' in the object field
Views
Replies
Total Likes
You need to place the following in the exit event of the field..
You can also place a messageBox to the user if you want..
Place it in Exit event.
var minLength = 2;
if(NumericField1.rawValue.toString().length <minLength){
xfa.host.messageBox("Minimum 2 Numbers are needed");
xfa.host.setFocus(this);
}
Thanks
Srini
Views
Replies
Total Likes
Thank you for your help. I have tried what you suggesting and it is still not working. Would a message come up automatically if the minimum number has not been entered?
Views
Replies
Total Likes
Use the following in Exit event..
var minLength = 2;
if(NumericField1.rawValue.toString().length <minLength){
xfa.host.messageBox("Minimum 2 Numbers are needed");
xfa.host.setFocus(this);
}
Thanks
Srini
Views
Replies
Total Likes
if the minimum amount has not been entered, when you either hit enter or tab will a error message come up? or will it only give a warning at the end when the user hits validate?
Views
Replies
Total Likes
Try this code in the exit event..If you do not enter any value in the NumericField, you need to directly display the message and set focus to the field.
var minLength = 2;
if(NumericField1.rawValue != null){
if(NumericField1.rawValue.toString().length <minLength){
xfa.host.messageBox("Minimum 2 Numbers are needed");
xfa.host.setFocus(this);
}
}
else{
xfa.host.messageBox("Minimum 2 Numbers are needed");
xfa.host.setFocus(this);
}
Thanks
Srini
Views
Replies
Total Likes
Im not sure what I am doing wrong. I am copying exactly what you suggested....
Views
Replies
Total Likes
Can you send the form so I can have a look at it..
Please mention which field on the form is giving the error..
Thanks
Srini
Views
Replies
Total Likes
Here is the updated form..
https://acrobat.com/#d=CHbixTuuKW*X*uFac4c6JQ
Few things I changed..
1) Removed the Validation pattern and Validation script message.
2) I am checking the input in the Change event and Exit event for Registration and ID fields.
My code is checking to have the minimum/ maximum values for both the fields. So user cannot leave the field without entering any input.
If you want to allow the user to leave the field with out entering input, then comment out the else part in Exit event code.
Hope this helps..
Thanks
Srini
Views
Replies
Total Likes
Thankyou very much for your help, i appreciate it.
Views
Replies
Total Likes
is it possible to have a minimum and maximum ONLY if a number is entered? i do not want this to be a required field but right now the way it is set up the user has to fill in the field. i would like the user to be able to tab past this field if they dont know the number. is this possible?
Views
Replies
Total Likes
You can try commenting out the else part of the code earlier (which is usually gets executed only when the field is null)..
By commenting that, you are allowing the user leave the field without entering a value in it..
Thanks
Srini
Views
Replies
Total Likes
Ok, what am I doing wrong? I need to set a minimum amount of characters to be entered in a text field and I keep getting syntax errors when testing it...here is the code I am putting in on the mouseexit click.
var minLength = 2
if(Username.rawValue.toString().length <minLength)
then xfa.host.messageBox("Username must be 2-16 characters in length!”)
else xfa.host.setFocus(this)
endif
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies