forms - 发帖前检查
问题描述
我正在使用 express,这是我的 html 文件代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>title</title>
</head>
<body>
<form action="/createaccount" method = "POST">
<p>Username</p>
<input name="username" type="text" value="username">
<p>Password</p>
<input name="password" type="password" value="password">
<input type="submit">
</body>
</html>
我想在发布之前检查是否没有输入
解决方案
<input name="username" type="text" value="username" required>
在输入字段中添加必需
如果您想在服务器端进行验证,请使用 express-validator https://express-validator.github.io/docs/
推荐阅读
- openstack - ubuntu 上的 microstack 没有注册 cinder 卷服务
- opengl - 如何从前向矢量计算俯仰和偏航值
- .net-core - 在 identotyserver 4 中的 API(资源)中引发错误
- react-native - GraphQl 生成语法错误:预期 $,找到 {]
- php - 如何向 ElasticSearch Aggregation (min/max) 添加条件?
- python - Apache/mod_wsgi ModuleNotFoundError
- android - 可绘制文件夹中的图片不起作用 - 为什么?
- azure - 如何修复 azure wiki 中的 toc 超链接锚滚动位置(当存在重复的锚时 - 例如:子主题)?
- linux - BASH:尝试读取文件但它只获取第一行
- javascript - 如何用一个按钮更改多个按钮的文本值但值不同?