Home > Web Front-end > JS Tutorial > JAVASCRIPT client-side verification data legality code (regular) page 1/2_javascript skills

JAVASCRIPT client-side verification data legality code (regular) page 1/2_javascript skills

PHP中文网
Release: 2016-05-16 18:29:34
Original
1241 people have browsed it

JAVASCRIPT The legality code of the client verification data is relatively complete, so it is simply paginated and friends who like it can save it.

Copy code The code is as follows:




http://www.php.cn/;input type="text" name="url" value ="">



javascript verification Complete list of forms
1. Length limit

Copy code The code is as follows:


<script> <br>function test() <br>{ <br>if(document.a.b.value.length>50) <br>{ <br>alert("Cannot exceed 50 characters!"); <br>document.a.b.focus(); <br>return false; <br>} <br>} <br></script>





2. Can only be Chinese characters

3." It can only be in English

Copy code The code is as follows:





7. Block keywords (*** and **** are blocked here)

Copy code The code is as follows:




< ;input type=text name=b>



8. Check whether the password entered twice is the same

Copy the code The code is as follows:







<script> <br>function check( ) <br>{ <br>with(document.all){ <br>if(input1.value!=input2.value) <br>{ <br>alert("false") <br>input1.value = " "; <br>input2.value = ""; <br>} <br>else document.forms[0].submit(); <br>} <br>} <br></script>


That's enough :)
It's cool to block the right click
oncontextmenu="return false" ondragstart="return false" onselectstart="return false"
Add to body
2
2.1 Form items cannot be empty

Copy code The code is as follows:




2.3 Form items can only be numbers and "_", which are used for phone/bank account verification and can be extended to domain name registration, etc.

Copy code The code is as follows:




2.4 Form item input value/length limit

Copy code The code is as follows:




2.5 Chinese/English/Number/ Determining the validity of email addresses

Copy code The code is as follows:




2.6 限定表单项不能输入的字符

复制代码 代码如下:




1. 检查一段字符串是否全由数字组成
---------------------------------------

2. 怎么判断是否是字符
---------------------------------------
if (/[^x00-xff]/g.test(s)) alert("含有汉字");
else alert("全是字符");
3. 怎么判断是否含有汉字
---------------------------------------
if (escape(str).indexOf("%u")!=-1) alert("含有汉字");
else alert("全是字符");

当前1/2页 12下一页阅读全文

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template