写一个html页面,包括一个文本输入框用来输入手机号,一个按钮用来提交手机号,一个文本框用来输入短信验证码,一个按钮用来提交验证码
时间: 2023-03-13 11:48:28 浏览: 155
<html>
<body>
<form>
<input type="text" name="phoneNum" placeholder="请输入手机号"/>
<input type="button" value="提交手机号" onclick="submitPhoneNum()"/>
<input type="text" name="verifyCode" placeholder="请输入短信验证码"/>
<input type="button" value="提交验证码" onclick="submitVerifyCode()"/>
</form>
</body>
</html>
相关问题
写一个html页面,包括一个文本输入框用来输入手机号,一个按钮用来向active.php提交手机号,一个文本框用来输入短信验证码,一个按钮用来向reg.php提交验证码
<html>
<head>
<title>注册页面</title>
</head>
<body>
<form action="" method="post">
<div>
<label>请输入手机号:</label>
<input type="text" name="phone_number" />
</div>
<div>
<input type="submit" value="提交" name="submit_active" formaction="active.php" />
</div>
<div>
<label>请输入短信验证码:</label>
<input type="text" name="sms_code" />
</div>
<div>
<input type="submit" value="提交" name="submit_reg" formaction="reg.php" />
</div>
</form>
</body>
</html>
设计一个用户注册页面,显示当前日期、时间和星期几。注册内容包括用户名,密码及密码确认框,性别,邮箱,手机号码,一个提交按钮,一个重写按钮(清空所有文本框内容 )。要求检测密码长度为8-12位,检测密码组成需由英文大小写字母和数字组成,检测邮箱格式是否正确,检测手机号码是否是11位。
以下是一个简单的用户注册页面代码示例,包括了显示当前日期、时间和星期几、用户名、密码及密码确认框、性别、邮箱、手机号码、提交按钮和重写按钮,以及对密码长度、密码组成、邮箱格式和手机号码格式的检测:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>User Registration</title>
<script>
function displayDateTime() {
var now = new Date();
var date = now.getDate();
var month = now.getMonth() + 1;
var year = now.getFullYear();
var day = now.getDay();
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes;
seconds = seconds < 10 ? '0'+seconds : seconds;
var dateTime = month + '/' + date + '/' + year + ' ' + hours + ':' + minutes + ':' + seconds + ' ' + ampm;
document.getElementById('datetime').innerHTML = dateTime;
document.getElementById('day').innerHTML = days[day];
}
setInterval(displayDateTime, 1000);
function validateForm() {
var name = document.forms["registration"]["name"].value;
var password = document.forms["registration"]["password"].value;
var confirmPassword = document.forms["registration"]["confirm-password"].value;
var gender = document.forms["registration"]["gender"].value;
var email = document.forms["registration"]["email"].value;
var phone = document.forms["registration"]["phone"].value;
if (name == "") {
alert("Name must be filled out");
return false;
}
if (password == "") {
alert("Password must be filled out");
return false;
}
if (password.length < 8 || password.length > 12) {
alert("Password length should be between 8 and 12 characters");
return false;
}
if (!/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,12}$/.test(password)) {
alert("Password should contain at least one lowercase letter, one uppercase letter and one digit");
return false;
}
if (password != confirmPassword) {
alert("Passwords do not match");
return false;
}
if (gender == "") {
alert("Gender must be selected");
return false;
}
if (email == "") {
alert("Email must be filled out");
return false;
}
if (!/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(email)) {
alert("Email format is invalid");
return false;
}
if (phone == "") {
alert("Phone number must be filled out");
return false;
}
if (!/^\d{11}$/.test(phone)) {
alert("Phone number should be 11 digits");
return false;
}
return true;
}
function resetForm() {
document.forms["registration"].reset();
}
</script>
</head>
<body>
<h1>User Registration</h1>
<form name="registration" onsubmit="return validateForm()">
<fieldset>
<legend>Personal Information</legend>
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password"><br>
<label for="confirm-password">Confirm Password:</label>
<input type="password" id="confirm-password" name="confirm-password"><br>
<label for="gender">Gender:</label>
<select id="gender" name="gender">
<option value="" selected disabled hidden>Select Gender</option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br>
<label for="phone">Phone:</label>
<input type="tel" id="phone" name="phone"><br>
</fieldset>
<input type="submit" value="Submit">
<input type="button" value="Reset" onclick="resetForm()">
</form>
<p id="datetime"></p>
<p id="day"></p>
</body>
</html>
```
在这个页面中,我们使用了JavaScript来实现日期、时间和星期几的显示,并使用了HTML5表单验证来检测表单中各个字段的输入是否合法。其中:
- `displayDateTime()`函数用于在页面上显示当前日期、时间和星期几。我们使用了`setInterval()`函数来不断地更新显示内容,以保证显示的时间是最新的。
- `validateForm()`函数用于检测表单中各个字段的输入是否合法。我们使用了JavaScript的正则表达式来检测密码长度、密码组成、邮箱格式和手机号码格式。
- `resetForm()`函数用于清空表单中各个输入框的内容,以便用户重新填写。
你可以将这段代码复制到一个HTML文件中,然后在浏览器中打开该文件,即可看到一个用户注册页面。
阅读全文