mirror of
https://github.com/aljazceru/cryptoanarchywiki.github.io.git
synced 2025-12-17 13:14:21 +01:00
Add post
This commit is contained in:
@@ -6,23 +6,6 @@ categories: [others]
|
|||||||
---
|
---
|
||||||
|
|
||||||
This javascript will validate/allow the number only when event key is pressed.
|
This javascript will validate/allow the number only when event key is pressed.
|
||||||
|
|
||||||
{% highlight html %}
|
|
||||||
<input id="id_price" type="number" min=0 />
|
|
||||||
<script type="text/javascript">
|
|
||||||
function isNumber(evt) {
|
|
||||||
evt = (evt) ? evt : window.event;
|
|
||||||
var charCode = (evt.which) ? evt.which : evt.keyCode;
|
|
||||||
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
document.getElementById('id_price').setAttribute("onkeypress", "return isNumber(event)");
|
|
||||||
</script>
|
|
||||||
{% endhighlight %}
|
|
||||||
|
|
||||||
|
|
||||||
For example result of it:
|
For example result of it:
|
||||||
|
|
||||||
<iframe width="100%" height="300" src="//jsfiddle.net/agaust/3qz105nn/embedded/html,result/dark/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
<iframe width="100%" height="350" src="//jsfiddle.net/agaust/3qz105nn/embedded/html,result/dark/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
||||||
Reference in New Issue
Block a user