Quantcast
Channel: Adobe Community : All Content - LiveCycle Designer
Viewing all articles
Browse latest Browse all 5571

Javascript for 5 or 9 zip code?

$
0
0

I have a form where I want to do a five to nine zip code; if the user inputs anything else, it is will be deemed invalid and the field will be empty when the user presses "enter."

 

So far, in the change event, I have the following script that only allows 9 digits, meaning the user cannot input more than 9 digits:

 

     var maxLength = 9;

     if(xfa.event.newText.length >maxLength)xfa.event.change = "";

 

Then in the exit event, I have the following script that only allows numerical digits:

 

if(this.rawValue==null){this.execValidate();}

if (!/^[0-9]{5,9}$/i.exec(this.rawValue)) {

  this.rawValue= null;

}

 

The problem is that it's still allowing entries like "123456" or "1234567" or "12345678." I only want users to be able to enter a 5-digit or 9-digit zip code.

 

Please let me know if there is anything I can do to resolve this issue.


Viewing all articles
Browse latest Browse all 5571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>