GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — study/02_JavaScript/docment/getElementById.html at master · ItJava/study

Expand file tree

/

getElementById.html

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
43 lines (28 loc) · 914 Bytes
/

getElementById.html

Copy path

File metadata and controls

43 lines (28 loc) · 914 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>GetElementById</title>
<script type="text/javascript">
/*
需求:当用户点击了校验按钮,要获取输入框内容,然后验证是否合法
校验规则:必须由字母、数字、下划线组成 并且长度是5-12位
*/
function onclickFun() {
var usernameObj=document.getElementById("username");
var userNameText=usernameObj.value;
alert(userNameText);
var patt=/^\w{5,12}$/;
if(patt.test(userNameText)){
alert("用户名合法");
}else {
alert("用户名不合法!");
}
}
</script>
</head>
<body>
用户名:<input type="text" id="username" value="汪方晨">
<button onclick="onclickFun()">校验</button>
</body>
</html>
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.