我正在使用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>
我想在发布之前检查是否没有输入内容
答案 0 :(得分:0)
<input name="username" type="text" value="username" required>
在输入字段中添加必填
如果要在服务器端进行验证,请使用express-validator https://express-validator.github.io/docs/