mirror of
https://github.com/aljazceru/cryptoanarchywiki.github.io.git
synced 2025-12-17 05:04:21 +01:00
1.0 KiB
1.0 KiB
layout, title, date, categories
| layout | title | date | categories | |
|---|---|---|---|---|
| post | Javascript Validator for Input Number | 2016-04-26 04:19:22 +0700 |
|
This javascript will validate/allow the number only when event key is pressed. For example result of it:
tutorial above, when you can not directly add the attribute inside html tag. but if you can add it, you can following this tutorial bellow:
{% highlight html %}
<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; } </script>{% endhighlight %}
Refference: http://stackoverflow.com/a/7295864
hope it usefull.