I recently had a programming challenge where I had to find the sum of the first X prime numbers in JavaScript in a slightly compressed format, and couldn't find anything decent online.
So I coded this.
It could be far better, although the challenge was timed :P
Thanks to The Polyglot Developer for their "isPrime" function :)
Sunday, December 18, 2016
Wednesday, November 23, 2016
A Textbox that only allows numbers
Since this seems so hard to do... An actual working example :)
Usage HTML: <input type="text" onkeypress="return isNumericKeyPress(event.keyCode);" onpaste="isNumericPaste(this);" />
OR
ASP.NET: <asp:textbox ID="txtNumsOnly" runat="server" onkeypress="return isNumericKeyPress(event.keyCode);" onpaste="isNumericPaste(this);"></asp:textbox>
Demo Type or paste something:
Samples
- 1!2@3#
- Test
- Test1
- 1a2b3c
Usage HTML: <input type="text" onkeypress="return isNumericKeyPress(event.keyCode);" onpaste="isNumericPaste(this);" />
OR
ASP.NET: <asp:textbox ID="txtNumsOnly" runat="server" onkeypress="return isNumericKeyPress(event.keyCode);" onpaste="isNumericPaste(this);"></asp:textbox>
Demo Type or paste something:
Samples
- 1!2@3#
- Test
- Test1
- 1a2b3c
Subscribe to:
Posts
(
Atom
)