我需要对表单中的三个字段进行验证。
当我没有提交任何内容时,即使我有要求,它们也会提交到数据库,这会使我的程序崩溃。
<button class="btn btn-info btn-lg" type="button" data-toggle="modal"
data-target="#myModal" tabindex="-1">Add</button>
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header"><button class="close" type="button" data-
dismiss="modal">×</button>
<h4 class="modal-title">Add Work Order/Service Request</h4>
</div>
<div class="modal-body">
<div class="popup">
<form action="{{ url_for('background_process') }}" method="POST">
<input type="text" id="name" name="name" required />
<input type="url" id="url" name="url" required />
<input type ="text" id="mdp-demo" name= "mdp-demo" required />
<a href=# id=process_input><button
class='btn btn-default'>Submit</button></a>
</form>
</div>
</div>
</div>
</div>
有人知道原因吗?
答案 0 :(得分:0)
<!DOCTYPE html><html>
<head>
</head>
<body>
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div class="popup">
<form action="{{ url_for('background_process') }}" method="POST">
<input type="text" id="name" name="name" required />
<input type="url" id="url" name="url" required />
<input type ="text" id="mdp-demo" name= "mdp-demo" required />
<a href=# id=process_input><button
class='btn btn-default' >Submit</button></a>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
我使用了相同的代码,但是它给了我