SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Apr 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question OnPaste Checking Problem

    I use the following code for checking whether an input is a number or not and if it is not a number the textbox does not accept the input

    <input type="text" id="..." onKeypress="jvascript:checknumber(...);" />

    it works fine.

    But if I write the same code for checking the same when the input is getting pasted it fails:

    i.e.,
    <input type="text" id="..." onPaste="jvascript:checknumber(...);" onDrop="jvascript:checknumber(...);" />

    or

    <input type="text" id="..." onPaste="jvascript:return checknumber(...);" onDrop="jvascript:return checknumber(...);" />

    the above code does not work.
    But the following code works fine

    <input type="text" id="..." onPaste="return false;" onDrop="return false;" />

    Does anyone have any idea what I should do ?

  2. #2
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    813
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess there is no onDrop and onPaste events. just check with you how do you write your checknumber function? you can use onchange event.

  3. #3
    SitePoint Addict
    Join Date
    Apr 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess there is no onDrop and onPaste events. just check with you how do you write your checknumber function? you can use onchange event.
    Yes, there are onDrop and onPaste events.
    It may be browser dependent.

    I will try with OnChange event.

    thank you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •