search
HomeWeb Front-endJS Tutorialjs limit number js limit input implementation code_javascript skills

1. Only Chinese characters can be input
Copy code The code is as follows:



2. Only numbers can be entered
Copy code The code is as follows:



Simple prohibition of inputting Chinese characters
Copy code The code is as follows:



Enter numbers and decimal points:
Copy code The code is as follows:

onkeyup="value=value.replace(/[^d{1,}.d{1,}|d{1,}]/g,'')"

javascript can only enter numbers and ":".2007-11-24 15:50
Only numbers and ":" can be used, for example, when entering time.
Copy code The code is as follows:



Only letters and equal signs can be entered, but Chinese characters cannot be entered.

Other things:
Script javascript that can only enter numbers- -
Copy code The code is as follows:



The first half of the sentence means that keyboard typing can only be numbers, and the second half of the sentence means that pasting can only be numbers
Copy code The code is as follows:




3. JavaScript limits only numbers and English to be entered
Copy code The code is as follows:

function isregname( checkobj)
{
var checkOK = "0123456789 -_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var checkStr = checkobj;
var allValid = true;
var decPoints = 0;
for (i = 0; i {
ch = checkStr.charAt(i);
for (j = 0; j if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
return (allValid)
}
----------------
if(!(isregname(obj.loginname.value))){
alert("[Member code] does not comply with the specification, member code It can only be English letters or numbers");
obj.loginname.focus();
return(false);
}
if(!(isregname(obj.password.value))) {
alert("[Password] does not meet the specifications, the password can only be English letters or numbers");
obj.password.focus();
return(false);
}

4.javascript can only input English and numbers into the input box
Copy code The code is as follows:



5. You can use Javascript to check the text box and filter out non-0-9 characters
Copy code The code is as follows:

[url=http://blog.csdn.net/xujh/admin/EditPosts.aspx] [/url]

6. Only the IP address format can be entered in the text box
Copy code The code is as follows:






<script> <BR>function mask(obj ){ <BR>obj.value=obj.value.replace(/[^d]/g,'') <BR>key1=event.keyCode <BR>if (key1==37 || key1==39) <BR>{ obj.blur(); <BR>nextip=parseInt(obj.name.substr(2,1)) <BR>nextip=key1==37?nextip-1:nextip 1; <BR>nextip= nextip>=5?1:nextip <BR>nextip=nextip<=0?4:nextip <BR>eval("ip" nextip ".focus()") <BR>} <BR>if(obj.value. length>=3) <BR>if(parseInt(obj.value)>=256 || parseInt(obj.value)<=0) <BR>{ <BR>alert(parseInt(obj.value) "IP Wrong address! ") <BR>obj.value="" <BR>obj.focus() <BR>return false; <BR>} <BR>else <BR>{ obj.blur(); <BR>nextip=parseInt( obj.name.substr(2,1)) 1 <BR>nextip=nextip>=5?1:nextip <BR>nextip=nextip<=0?4:nextip <BR>eval("ip" nextip ".focus ()") <BR>} <BR>} <BR>function mask_c(obj) <BR>{ <BR>clipboardData.setData('text',clipboardData.getData('text').replace(/[^d ]/g,'')) <BR>} <BR></script>
IP address input

IP address input

.
.
.



> ;
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
禁用Win11输入体验指南禁用Win11输入体验指南Dec 27, 2023 am 11:07 AM

最近有很多win11遇到了输入体验对话框总是闪烁,关也关不掉的问题,这其实是由于win11的默认系统服务和组件导致的,我们需要先禁用相关服务,再禁用输入体验服务就可以解决了,下面一起来试试看吧。win11输入体验怎么关闭:第一步,右键开始菜单,打开“任务管理器”第二步,依次找到“CTF加载程序”、“MicrosoftIME”和“服务主机:Textinputmanagementservice”三个进程,右键“结束任务”第三步,打开开始菜单,在上方搜索并打开“服务”第四步,在其中找到“Textinp

Windows输入遇到挂起或内存使用率高的问题[修复]Windows输入遇到挂起或内存使用率高的问题[修复]Feb 19, 2024 pm 10:48 PM

Windows的输入体验是一个关键的系统服务,负责处理来自各种人机接口设备的用户输入。它在系统启动时自动启动,在后台运行。然而,有时候这个服务可能会出现自动挂起或占用过多内存的情况,导致系统性能下降。因此,及时监控和管理这个进程是至关重要的,以确保系统的效率和稳定性。在这篇文章中,我们将分享如何解决Windows输入体验被挂起或导致内存使用率高的问题。Windows输入体验服务没有用户界面,但它与处理与输入设备相关的基本系统任务和功能有密切关联。它的作用是帮助Windows系统理解用户输入的每一

如何设置CentOS系统以限制用户对系统日志的修改如何设置CentOS系统以限制用户对系统日志的修改Jul 05, 2023 pm 03:43 PM

如何设置CentOS系统以限制用户对系统日志的修改在CentOS系统中,系统日志是非常重要的信息源,它记录了系统的运行状态、错误信息、警告等。为了保护系统的稳定性和安全性,我们应该限制用户对系统日志的修改。本文将介绍如何设置CentOS系统,实现对系统日志的修改权限限制。一、创建用户组和用户首先,我们需要创建一个专门负责管理系统日志的用户组,以及一个用于管理

解决win11搜索栏输入问题解决win11搜索栏输入问题Dec 26, 2023 pm 12:07 PM

搜索栏是win11系统中非常好用的功能,可以帮助我们找到想要的设置、功能和服务等。但是有的朋友遇到了win11搜索栏无法输入的情况,我们可以在注册表中修改相关数据来解决,下面就跟着小编一起来解决一下吧。win11搜索栏无法输入怎么办1、首先我们可以按下键盘的“win+r”调出运行。2、然后在其中输入“regedit”回车确定打开注册表编辑器。3、然后在上方路径中输入“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Expl

JavaScript 如何实现图片的拖动缩放同时限制在容器内?JavaScript 如何实现图片的拖动缩放同时限制在容器内?Oct 20, 2023 pm 04:19 PM

JavaScript如何实现图片的拖动缩放同时限制在容器内?在Web开发中,经常会遇到需要对图片进行拖动和缩放的需求。这篇文章将介绍如何使用JavaScript实现图片的拖动缩放,并限制在容器内的操作。一、拖动图片要实现图片的拖动,我们可以使用鼠标事件来跟踪鼠标位置,并将图片的位置随之移动。下面是一个示例代码://获取图片元素varimage

word矩阵怎么输入word矩阵怎么输入Mar 19, 2024 pm 11:00 PM

矩阵是我们经常使用和遇到的公式,但是在word里如何输入矩阵你会操作吗?很多人可能没有接触过,遇到使用的时候就会感觉困惑,那么,这里我们就跟大家分享一下word矩阵怎么输入。希望经过这个技巧的分享,能够给你带来帮助和启发。1、首先,新建并打开一个word文档,为了演示操作,我们就使用空白文档进行演示。如下图所示:2、我们要输入矩阵,需要在菜单栏找到【插入】按钮,这个按钮可以插入很多内容选项,比如图片等都是从这个菜单栏完成。3、点击【插入】之后,我们工具选项右侧看,可以找到【公式】,然后我们点击【

MyBatis逆向工程的优势与限制MyBatis逆向工程的优势与限制Feb 22, 2024 pm 07:27 PM

MyBatis是一种流行的持久化框架,它提供了逆向工程的功能,这使得开发人员可以根据数据库中的表结构自动生成实体类、Mapper接口和XML映射文件。逆向工程是MyBatis的一个重要特性,它可以大大减少开发人员的工作量,并提高代码的可维护性。然而,逆向工程也有一些限制,本文将介绍MyBatis逆向工程的优势和限制,并通过具体的代码示例加以说明。首先,让我们

Nginx限制访问频率配置,防止恶意攻击Nginx限制访问频率配置,防止恶意攻击Jul 04, 2023 pm 05:01 PM

Nginx限制访问频率配置,防止恶意攻击随着互联网的发展,网站的安全性成为了一个重要的问题。为了防止恶意攻击,我们需要对访问频率进行限制。而Nginx作为一个高性能的Web服务器,可以通过配置来实现这个目标。Nginx提供了一个模块叫做limit_req_module,该模块可以限制访问频率。在进行配置之前,我们需要确保已经启用了该模块。在nginx.con

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download

Atom editor mac version download

The most popular open source editor