In input only numbers on js / ~#root -i In input only numbers on js / ~#root -i In input only numbers on js / ~#root -i In input only numbers on js / ~#root -i In input only numbers on js / ~#root -i In input only numbers on js / ~#root -i In input only numbers on js / ~#root -i In input only numbers on js / ~#root -i
  • RU
  • UA
  • EN
  • Create an online store
  • Documentation
  • Blog
    • Unix ОS
    • Php
    • MySQL
    • JavaScript
    • Package Managers
    • Docker
    • Seo
  • Auxiliary services
    • Short Links
    • Exchange views YouTube
  • Sign in
  • Create Account
  • Home
  • JavaScript
  • In input only numbers on js

In input only numbers on js

A simple JS script, filtering input information in input. Enter only numbers.

<input type="text" onkeypress="filterKey(event);">

function filterKey(k) {
// 48-56 - это [0-9]

if (!(k.keyCode >= 48 && k.keyCode <= 57)){
k.preventDefault();
return false;
}
}

When you press a key in a field, the script checks if it belongs to a range of numbers. If not, it interrupts key entry.

01 April 21
484
0

Comments

Name
E-mail
Rating
Review

Other articles from the category

02 February 2020

Move block in mobile version with jQuery

Let's consider how to move a block in the mobile version if it is located in a different place in the desktop version. Let's use JQuery.

29 January 2019

Gulp Error watch path ENOSPC in gaze.js or grunt.js

Let's consider a possible solution to the problem when running Gulp on Ubuntu 18.04 with an error Error: watch /path/ ENOSPC. Let's analyze what the max_user_watches parameters are.

21 May 2018

Code highlighting on the site using Js and Css

When describing minimal codes that have a syntax similar to C++, it may be necessary to have minimal highlighting on the site for better readability. I will give the easiest way to highlight, which I took from habrahabr. Consider, connect, describe ...

Categories

  • Unix OS
  • Php
  • MySQL
  • JavaScript
  • Package Managers
  • Docker
  • Seo

Latest comments

Добрый день, Сергей. Я на более новых версиях блют...
root-i
23.02.23
Пробовал на transmart колонке. Ничего из перечисле...
Сергей
20.02.23
HenryMit, может быть
root-i
07.02.23
Неофрейдизм — это… Определение, принципы, представ...
HenryMit
07.02.23

I share information in which I needed help and spent a lot of time figuring it out. If the information helped at least one person, then this site was not created in vain.

Thank you for the continuation of the site:
Contacts

Telegram Viber Mail

Search for articles

  • Sign in
  • Create Account

Powered by chmod -R