js+html 做一个注册页面 要求如下电子邮箱必须包含@和字符。 头像可以选择浏览 提交按钮和重填按钮
时间: 2024-05-06 07:15:49 浏览: 17
以下是一个基础的注册页面,满足您的要求:
```
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>注册页面</title>
</head>
<body>
<h1>注册页面</h1>
<form>
<label for="email">电子邮箱:</label>
<input type="email" id="email" name="email" required pattern=".*@.*">
<br><br>
<label for="avatar">头像:</label>
<input type="file" id="avatar" name="avatar">
<br><br>
<input type="submit" value="提交">
<input type="reset" value="重填">
</form>
</body>
</html>
```
在该页面中,`<input type="email">` 会自动验证输入的内容是否符合电子邮件格式,而 `required` 属性则要求该输入框不能为空。`pattern=".*@.*"` 则是为了保证邮箱中包含 `@` 字符。
至于头像的选择,我们使用了 `<input type="file">` ,用户可以通过浏览器选择本地的图片文件进行上传。
最后,我们使用了 `<input type="submit">` 和 `<input type="reset">` 分别作为提交和重填按钮。
注意:由于 JavaScript 与 HTML5 集成度很高,如果您需要在注册页面中加入更多的交互功能,就需要使用 JavaScript 来实现。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)