Link to home
Start Free TrialLog in
Avatar of asudhaa
asudhaa

asked on

onpaste not working in firefox

I have dynamically created textboxex,in which I would like to enter only numbers.This works fine.I would like to paste only numbers.This works in internet explorer .But in firefox i am able to paste text also.  I have used the following code

in C#
tb.Attributes.Add("onpaste", "return alloNumbersOnly(this);");//paste only nembers

in aspx

<script type="text/javascript">
      function alloNumbersOnly(obj) {
          var txt = window.clipboardData.getData('Text');
          if (isNaN(txt)) {
              alert('Please paste only numbers!');
              return false;
          }
      }
    </script>

How can I make this function work in firefox also ?
ASKER CERTIFIED SOLUTION
Avatar of Deja Anbu
Deja Anbu
Flag of Oman image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or try with onchange event , There is no onpaste event for Firefox .. ofcourse, onchange will fire not only for pasting..