This is a migrated thread and some comments may be shown as answers.

More than one decimal point

1 Answer 31 Views
Input
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 31 Jan 2014, 06:14 PM
Greetings,

I am trying to figure out which input control to use.  We have numeric account numbers that can have zero to many decimal points.  For example...

123456
123.456
12.345.6789
1234.5.6

These would all be valid account numbers.  I need to have an input that only allows numbers and periods.  Any advice?

Much appreciated,

Matt

1 Answer, 1 is accepted

Sort by
0
Matt
Top achievements
Rank 1
answered on 31 Jan 2014, 06:34 PM
Never mind, I found the documentation about OnKeyPress. Here is what I used...

<script type="text/javascript">
    function NumericPeriodOnly(sender, eventArgs) {
      var c = eventArgs.get_keyCode();
      if ((c < 48 || c > 57) && c !== 46)
        eventArgs.set_cancel(true);
    }
  </script>


Matt
Tags
Input
Asked by
Matt
Top achievements
Rank 1
Answers by
Matt
Top achievements
Rank 1
Share this question
or