Skip navigation
Garry4587xx
Currently Being Moderated

How to make text field only accpet digits?

Aug 21, 2010 4:12 AM

Hello everyone

 

I wann know how to make a text field only accpet digits (0,1,2 ...9)? In Acrobat, it's very easy to set, but in LiveCycle, looks it needs some custom JavaScript, can anyone please provide help?

 

The following codes can't work in LiveCycle, how to make it work?

 

if(!event.willCommit)
    event.rc = !isNaN(event.change) || event.change == "." || (event.change == "-" && event.selStart == 0);

 

Thanks

 
Replies
  • Currently Being Moderated
    Aug 21, 2010 1:57 PM   in reply to Garry4587xx

    Why not just use a numeric field?

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 22, 2010 12:55 AM   in reply to westlakejager

    Regular expressions are a good option. The following uses \D to match any character that is not a digit.

     

     

     

    // form1.page1.tf1::exit - (JavaScript, client)


    if (!(this.isNull)) {

      var tf1 = this.rawValue;

      var regExp = /\D/;

      if (regExp.test(tf1)) {

        xfa.host.messageBox("tf1 must be numeric");

      }

    }

     

     

    Steve

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points