Home >Web Front-end >JS Tutorial >JavaScript input box content format verification code_form effects

JavaScript input box content format verification code_form effects

WBOY
WBOYOriginal
2016-05-16 18:34:541175browse

Code

Copy code The code is as follows:


Username: < ;input type="text" id="name" />
//Verification results Display, note that display is hidden


Password: //pwd input box obtained The onfocus event is triggered when the focus is on, and the content format of the name input box is verified to be correct.
<script> <br>var name = document.getElementById("name"); <br>function bb(){ <br>d. style.display = 'block'; //Display div <br>if(name.value.match(/^w /)) { //Use regular expressions to verify the entered user name <br>d.innerHTML = " dui"; <br>} <br>else{ <br>d.innerHTML = "cuo"; <br>} <br>} <br></script>

Statement:
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