Home > front end >  "Event" of JavaScript
"Event" of JavaScript

Time:01-08

On the page to write a text input box, response focus leaves, when the focus away from discriminant of input in the input box number, if not, can only enter mathematics, JavaScript to write
For years, teaching

CodePudding user response:

For example

 & lt; html> 

<meta HTTP - equiv="content-type" content="text/HTML. Charset=utf-8 "& gt;
Sample
<script type="text/javascript"> Window. The onl oad=function () {
Document. The getElementById (" tField "). Onfocusout=function () {
if (! The (/^ \ d + $/document. GetElementById (" tField "). The value)) {
Alert (" can only input Numbers ");
//if you don't let go of focus, and is the document. The getElementById (" tField "). The focus ();
}
}
}
//- & gt; </script>

<body>




  • Related