HTML event handler return value

The basic syntax: onsubmit added in form form = "return value of the function";

Example code:

<! DOCTYPE HTML>
<HTML>
<head>
<Meta charset = "UTF-. 8">
<title> the Insert title here Wallpaper </ title>
<Script type = "text / JavaScript">
function showname () {
IF (Document. == form1.name1.value "") {
Alert ( "no entry");
return fasle;
} the else {
Alert ( "Welcome" + document.form1.name1.value);
return to true;
}
}
</ Script >
</ head>
<body>
<> h4 return values of the application event handler </ h4>
<form Action = "shijanchuli.html" name = "Form1" the onsubmit = "return showname ();"> // here form form name as set in the function corresponding to the function
name: // here onsubmit = "return showName ();If true then jump to "shijanchuli.html" is false if not Skip
<input type = "text" name = "name1" /> <br> // name value here also function in the function name corresponding to
<input type="submit" value="提交"/>
</form>


</body>
</html>

The role of the return value of the event handler is to extract the contents of form into the form of prompt is displayed in the browser interface, also a kind of a limitation of the HTML.

Results are as follows:

 

Click Submit after entering the name

Click que'di

Guess you like

Origin www.cnblogs.com/lianggegege123/p/12203998.html