Home > Web Front-end > JS Tutorial > body text

Detailed explanation of javascript form validation and Window_javascript skills

WBOY
Release: 2016-05-16 16:27:38
Original
1421 people have browsed it

1. Form verification form

1. Create a new form:

Copy code The code is as follows:


//Method 1: There is no length limit after the post is submitted, and the content is invisible after encoding.
//Method 2: The get submission has a length limit, and the encoded content is visible in the address bar
(input element)

2. The function of the form: it can transfer the URL and data to the database together.

3. Action attributes: action and confirmation button

When the user clicks the confirm button, the content of the form is transferred to another file. The form's action attribute defines the file name of the destination file. The file defined by the action attribute usually performs related processing on the input data received.

2. JavaScripeWindow--Browser Object Model

1. window object

All browsers support the Window object, which represents the browser window. Global variables are properties of the window object, and global functions are methods of the window object.

2. JsPopupAlert message box

1) Use of confirmation box

Copy code The code is as follows:


<script><br> function tijiao()<br> {<br> var zhi=confirm("Whether to submit");<br> if (zhi)<br> {<br> return true;<br> }<br> else<br> {<br> return false;<br> }<br> }<br> </script>

!--2. Usage of prompt box prompt-->
<script><br> function tijiao()<br> {<br> var zhi=prompt("Submit or not");<!--After clicking the submit button, a prompt script prompt box appears--><br> if (zhi)<br> {<br> return true;<br> }<br> else<br> {<br> return false;<br> }<br> }<br> </script>

3) Use of warning box alert

Copy code The code is as follows:






function y()
{
var yx=new RegExp(/^[0-9|A-z|_]{1,17}@[A-z|0-9]{1,5}.(com|cn|net|org|cc)$/) ;
var shuru=document.getElementById("youxiang").value;
if(yx.test(shuru))
{
alert("zhengque");
}
else
{
alert("cuowu");
}
}


3. Timing method

setTimeout(); execute code at some time in the future - using recursive method

clearTimeout();cancel setTimeout();

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