1. Only numbers and English can be entered:
2. Only numbers can be entered:
< ;input onkeyup="value=value.replace(/[^/d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/ d]/g,''))" ID="Text2" NAME="Text2">
3. Only full-width input is possible:
4. Only Chinese characters can be input:
--------------------------------------------- ----------------------------------------
Verify illegal characters, sql
function vdf()
{
var i,j,name,value,message,length,type,a=vdf.arguments,cb_name;
for (i=0; i{
if (a[i].indexOf('#')!=-1)
{
name=fob(a[i]. substr(0,a[i].indexOf('#')));
cb_name=fob(a[i].substr((a[i].indexOf('#') 1),a[i ].length));
}
else
{
name=fob(a[i]); // Control name
}
message=a[i 1]; // Prompt message
type=a[i 2]; // Type
if (type!="r_time")
{
value=name.value.replace(/ /g, " "); // Control value
}
else
{
value=name.value;
}
}
---------- -------------------------------------------------- ------------------
// =============== Determine whether the check box is selected====== =========== //
if (type=="r_cb")
{
e=document.forms(0).elements;
var flag=false ;
for (i=0;i
if (e[i]!=cb_name)
{
if (e[i].checked ==true)
{
flag=true;
break;
}
}
if (i==e.length-1)
{
break ;
}
}
if (flag==false)
{
alert(message "!/n"); //The prompt that appears when it is empty
return false;
}
}
// =============== Determine whether the drop-down box is selected ================ / /
if (type=="r_sl")
{
if (name.selected==false)
{
alert(message "!/n"); //Empty The prompt that appears when
return false;
}
}
// =============== Judgment that it cannot be empty ======= ========= //
if (type=="r")
{
if (value=="") // Determine whether it is empty
{
alert(message "!/n"); //The prompt that appears when it is empty
name.focus();
name.select();
return false;
}
}
// =============== Cannot be empty, but does not get focus ================ //
if (type=="o_r")
{
if (value=="") // Determine whether it is empty
{
alert(message "!/n"); / / Prompt that appears when it is empty
return false;
}
}
// =============== Only Chinese can be entered ===== =========== //
if (type=="r_china")
{
if (value.search(/^[/u4e00-/u9fa5] $/) ==-1)
{
alert(message "!/n"); // The judgment cannot be empty
name.focus();
name.select();
return false;
}
}
// =============== Cannot be empty, must be a number or character. ========== ====== //
if (type=="r_num_char")
{
if (value=="")
{
alert(message "!/n" ); //The prompt that appears when it is empty
name.focus();
name.select();
return false;
}
if (value.search(/^[ 0-9a-zA-Z] $/)==-1)
{
alert(message "!/n"); //The prompt that appears when it is empty
name.focus();
name.select();
return false;
}
}
// =============== Can be empty, not empty When, fill in the number ================ //
if (type=="num")
{
if (value.search(/^[ 0-9] $/)==-1 && value!="")
{
alert(message "!/n"); // The judgment cannot be empty
name.focus();
name.select();
return false;
}
}
// =============== cannot be empty, must be a number Judgment ================ //
if (type=="r_num")
{
if (value=="")
{
alert(message "!/n");
name.focus();
name.select();
return false;
}
if (value.search( /^[0-9] $/)==-1)
{
alert(message "!/n"); // The judgment cannot be empty
name.focus();
name.select();
return false;
}
}
// ===============Must enter a number less than n==== ============ //
if (type.indexOf("r_num{
length=type.substring((type.indexOf ('if (value=="") // Prompt for empty
{
alert(message "!/n");
name.focus();
name.select();
return false;
}
if (value.search(/^[0-9 ] $/)==-1) // Not made of numbers
{
alert(message "!/n");
name.focus();
name.select() ;
return false;
}
if (value.length>length) // Limit the length of the number
{
alert(message "!/n");
name.focus();
name.select();
return false;
}
}
// ===============Must enter a number greater than n================ //
if (type .indexOf("r_num>")!=-1)
{
length=type.substring((type.indexOf('>') 1),type.length); // Get the back of rnif (value=="") // Prompt for empty
{
alert(message "!/n");
name.focus();
name .select();
return false;
}
if (value.search(/^[0-9] $/)==-1) // Not made of numbers
{
alert(message "!/n");
name.focus();
name.select();
return false;
}
if (value.length{
alert(message "!/n");
name.focus();
name.select();
return false ;
}
}
// ===============Must enter a number between a-b ============= === //
if (type.indexOf("r_num#")!=-1)
{
length=type.substr((type.indexOf('>' ) 1),type.length);
length=length.substr(0,length.lastIndexOf("-"));
length1=type.substring((type.indexOf('-') 1) ,type.length) // Get the number after rnif (value=="") // Prompt for empty
{
alert(message "!/n");
name.focus();
name.select();
return false;
}
if (value.search(/^[0-9] $/)==-1) // Not a reminder made of numbers
{
alert(message "!/n");
name.focus();
name.select();
return false;
}
if (value.length
{
alert(message "!/n");
name. focus();
name.select();
return false;
}
}
// =============== cannot be empty , must be of float type================ //
if (type=="r_float")
{
if (value=="")
{
alert(message "!/n");
name.focus();
name.select();
return false;
}
if ( value.search(/^[0-9] $/)!=-1 || value.search(/^([0-9] )|([0-9] /.[0-9]*)| ([0-9]*/.[0-9] )$/)!=-1)
{
return true;
}
else
{
alert( message "!/n"); // The judgment cannot be empty
name.focus();
name.select();
return false;
}
}
/ / =============== To determine the email, you do not have to enter ================ //
if (type.indexOf(" email")!=-1)
{
if (name.value!="")
{
if (value.search(/^[_/.a-z0-9] @[a-z0-9] [/.][a-z0-9]{2,}$/i)==-1)
{
alert(message "!/n");
name.focus();
name.select();
return false;
}
}
}
// ========== =====To determine email, be sure to enter================ //
if (type.indexOf("r_email")!=-1)
{
if (name.value=="")
{
alert(message "!/n");
name.focus();
name.select();
return false;
}
if (value.search(/^[_/.a-z0-9] @[a-z0-9] [/.][a-z0-9]{2 ,}$/i)==-1)
{
alert(message "!/n");
name.focus();
name.select();
return false;
}
}
// =============== Determine the date, such as 2000-12-20============ ===== //
if (type=="r_date")
{
flag=true;
getdate=value;
if (getdate.search(/^[0 -9]{4}-(0[1-9]|[1-9]|1[0-2])-((0[1-9]|[1-9])|1[0-9 ]|2[0-9]|3[0-1])$/)==-1) // Correct when judging the input format
{
flag=false;
}
else
{
var year=getdate.substr(0,getdate.indexOf('-')) // Get the year
// The following operation is to get the month
var transition_month=getdate.substr(0, getdate.lastIndexOf('-'));
var month=transition_month.substr(transition_month.lastIndexOf('-') 1,transition_month.length);
if (month.indexOf('0')== 0)
{
month=month.substr(1,month.length);
}
// The following operation is to obtain the date
var day=getdate.substr(getdate.lastIndexOf(' -') 1,getdate.length);
if (day.indexOf('0')==0)
{
day=day.substr(1,day.length);
}
//alert(month);
//alert(day)
//return false;
if ((month==4 || month==6 || month==9 || month==11) && (day>30)) // The dates in 4, 6, 9 and 11 months cannot exceed 30
{
flag=false;
}
if (month= =2) // Determine February
{
if (LeapYear(year))
{
if (day>29 || day}
else
{
if (day>28 || day}
}
else
{
flag=true ;
}
}
if (flag==false)
{
alert(message "!/n"); //The prompt that appears when it is empty
name.focus ();
name.select();
return false;
}
}
1. Length limit
<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
4. Can only be numbers
7. Block keywords (*** and **** are blocked here)
8. Twice Are the input passwords the same?
<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
Two
2.1 Table Single item cannot be empty
2.2 Compare whether the values of two form items are the same
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.
> ;
2.4 Form item input value/length limit
> ;
2.5 Chinese/English/numeric/email address validity judgment
> ;
2.6 Limit the characters that cannot be entered in form items
1. Check whether a string consists entirely of numbers
---------------------------------- ----
2. How to determine whether it is a character
---- ----------------------------------
if (/[^/x00-/xff]/ g.test(s)) alert("Contains Chinese characters");
else alert("All characters");
3. How to judge whether it contains Chinese characters
--------- -------------------------------
if (escape(str).indexOf("%u")!=- 1) alert("contains Chinese characters");
else alert("all characters");
4. Email format verification
---------------- -----------------------
//Function name: chkemail
//Function introduction: Check whether it is an Email Address
// Parameter description: String to be checked
//Return value: 0: Not 1: Yes
function chkemail(a)
{ var i=a.length;
var temp = a.indexOf ('@');
var tempd = a.indexOf('.');
if (temp > 1) {
if ((i-temp) > 3){
if ((i-tempd)>0){
return 1;
}
}
}
return 0;
}
5. Number format verification
---------------------------------------
//Function name: fucCheckNUM
//Function introduction: Check whether it is a number
//Parameter description: The number to be checked
//Return value: 1 means it is a number, 0 means it is not a number
function fucCheckNUM(NUM)
{
var i,j,strTemp;
strTemp="0123456789";
if ( NUM.length== 0)
return 0
for (i=0;i
j=strTemp.indexOf(NUM.charAt(i));
if (j==-1)
{
//Indicates that there are characters that are not Number
return 0;
}
}
//The description is number
return 1;
}
6. Phone number format verification
----- ----------------------------------
//Function name: fucCheckTEL
//Function introduction : Check whether it is a phone number
//Parameter description: The string to be checked
//Return value: 1 is legal, 0 is illegal
function fucCheckTEL(TEL)
{
var i,j,strTemp;
strTemp="0123456789-()# ";
for (i=0;i
j=strTemp.indexOf (TEL.charAt(i));
if (j==-1)
{
//Indicates that some characters are illegal
return 0;
}
}
//Explanation is legal
return 1;
}
7. Function to determine whether the input is Chinese
-------------------------- ------------------
function ischinese(s){
var ret=true;
for(var i=0;i
return ret;
}
8. Comprehensive function to judge the legality of user input
---------------------------------------

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6
Visual web development tools