Allow the use of the "plus" character in a text field.



I have a script on the change event that allows only numbers 1 to 100 and the values a,b,c,d,e,r,i,n. I also want to allow the "-" and "+" entries in the field.

The script below works for the entries, with the exception of the "+" character. How do i change the script so that the field allows an entry like A+, B+, etc.?

On change:

if (xfa.this.change!="" && !xfa.event.newText.match(/^[1-9][0-9]?$|^100|^(a|a-|b|b-|c|c-|d|d-|e|e-|r|n|i)$/)){

xfa.event.change ="";"Incorrect entry... Thanks!");


On exit:


Any help would be appreciated!


So I've altered the change script, but it seems less than efficient. It does work, and does restrict the values to the field correctly:

if (xfa.this.change!="" && !xfa.event.newText.match(/^[1-9][0-9]?$|^100|^(a|a\-|a\+|b|b\-|b\+|c|c\-|c\+|d|d\-|d\+|e|e\-|e\+|r|n|i)$/)){

xfa.event.change ="";"Incorrect entry... Thanks!");


But am still looking for a better way, if there is one.

Accepted Solutions (0)

Answers (0)