onpaste not working in firefox

Posted on 2011-05-06
Last Modified: 2013-12-07
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;

How can I make this function work in firefox also ?
Question by:asudhaa
    LVL 14

    Accepted Solution

    LVL 14

    Expert Comment

    Or try with onchange event , There is no onpaste event for Firefox .. ofcourse, onchange will fire not only for pasting..

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    I recently found myself in a Corporate Situation where the client had requested blocking access to any and all websites except his own Domain? Easy? I am sure this would be your answer but their requirement was, this has to be done without using…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
    Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now