I seem to be having an issue pasting code in my responses. This has happened to me in the past, but I think i'm able to reproduce the issue now. When I try to submit the post, it just hangs...

Here is a thread where I tried, but was unable to include the code in my response.

http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/466984/numeric-textbox-with-decimal-point

Attached is the snippet of code that I tried to include in a code block.

User Agent:
Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36

Recommended Answers

All 7 Replies

Try this conditional statement...

function isNumberKey(evt) {
     var charCode = (evt.which) ? evt.which : event.keyCode
     if (
         (charCode >= 48 && charCode <= 57) || 
         (charCode == 110 || charCode == 190) || 
         (charCode >= 96 && charCode <= 105) 
        )
     {
       return true;
     }
     else
     {
       alert("Enter Numeric data Only");      
       return false;
     }
}

Also, change the event from onkeypress to onkeyup.

onkeyup="return isNumberKey(event)";

see attached Pic.. this is what happens when i click "Submit your Reply". I'll try from a different PC/network at some point, and let you know if the problem follows. just wanted you to be aware in the event it affected anyone else..

c4b9d450bb264f7e656b38270deddd53

Are there any browser plugins or anything like that on the computer you're trying to use? It worked for me with absolutely no problems. I just copied/pasted what you had in the text file.

    function isNumberKey(evt) {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (
             (charCode >= 48 && charCode <= 57) || 
             (charCode == 110 || charCode == 190) || 
             (charCode >= 96 && charCode <= 105) 
            )
         {
           return true;
         }
         else
         {
           alert("Enter Numeric data Only");      
           return false;
         }
    }

Problem seems to be related to the network I was on. tried on different computers in the same network, same issue. No problems outside of the network. Possibly something going on with filtering of the traffic at the perimeter.

function isNumberKey(evt) {
         var charCode = (evt.which) ? evt.which : event.keyCode

    }

That's weird...as long as I dont have an if..else block, i can complete the process.

it definately sounds like some filtering rule is causing this issue here..

Ok, take care..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.