To limit it to 0-100, change it from any number of digits to any 2 digit number or 100.
how do i limit user choice to three options?
Collapse
X
-
I have decided to work with this approach for what I need to accomplish:
On change*
// Test input in real time. Only allow approved grades, r, i, n with the code on exit replacing n with na
if (xfa.event.chan ge!="" && !xfa.event.newT ext.match(/^[0-9]+?$|^(^n?)?$|^( r)?$|^(i)?$/)) {
xfa.event.chang e ="";
xfa.host.messag eBox("Oops, incorrect entry, Please correct your input. Thank you.");
}
Then on exit*
this.rawValue=t his.rawValue.re place(/n/g,"NA")
this.rawValue=t his.rawValue.to UpperCase()
The user is restricted to entering the three options "r", "i", or "n" where "n" is replaced by "na" on exit and all the values are also uppercased. The digits are limited to 3 by virtue of the field length limit.
I have no idea how to limit the number entries from 001 to 100, so that is unfortunate. I'm still open to some help on this! Thanks for all the input...Comment
-
How does this look? (I'm still getting an error when i input three digits like "560:...)
On change*
//Test input in real time. Only allow approved grades, r, i, na
if (xfa.this.chang e!="" && !xfa.event.newT ext.match(/^([1-9]{1,2}[0]?|100+|n|r|i)$/)) {
xfa.event.chang e ="";
xfa.host.messag eBox("Incorrect entry.. also, n outputs NA. Thanks!");
}
On exit*
this.rawValue=t his.rawValue.re place(/n/g,"NA")
this.rawValue=t his.rawValue.to UpperCase()Comment
-
Hello Rabbit,
I've amended the regex for the number entry:
//Test input in real time. Only allow approved grades, r, i, na
if (xfa.this.chang e!="" && !xfa.event.newT ext.match(/^[1-9][0-9]?$|^100|^(n?)?$ |^(r)?$|^(i)?$/)){
xfa.event.chang e ="";
xfa.host.messag eBox("Incorrect entry.. also, n outputs NA. Thanks!");
}
On exit*
this.rawValue=t his.rawValue.re place(/n/g,"NA")
this.rawValue=t his.rawValue.to UpperCase()
I think this time I've got it...Comment
-
Your first attempt is closer, your second one has a bunch of extra stuff for some reason, even on stuff that was working fine before.
Take the first attempt and fix that one. For example, your piece with the 100, you have a plus sign in there for some reason, that tells the expression to match as many zeroes as possible.
And for the piece that defines any two digit number, for some reason you tell it can have an optional zero at the end.Comment
-
You're right: messy code! How about this? It tests fine inside Livecycle ...
On change*
if (xfa.this.chang e!="" && !xfa.event.newT ext.match(/^[1-9][0-9]?$|^100|^(n|r|i )$/)){
xfa.event.chang e ="";
xfa.host.messag eBox("Incorrect entry.. also, n outputs NA. Thanks!");
}
On exit*
this.rawValue=t his.rawValue.re place(/n/g,"NA")
this.rawValue=t his.rawValue.to UpperCase()Comment
Comment