1
ユーザーがフォームに入力して[送信]ボタンを押した後に成功通知(Boostrap)を表示するフォームページがあります。私はdisplayプロパティにないnone
(ブロック、インライン、インラインブロック)の成功の警告メッセージが表示されるように、後に変更するにはどうすればよいNode-ExpressのPOSTアクション後にEJSの要素のスタイルを変更する
#success_message { display: none; }
:私のCSSではデフォルトで
<form class="well form-horizontal" action="/contact" method="post" id="contact_form">
... (input fields here)
<div class="alert alert-success" role="alert" id="success_message"> Success
<i class="glyphicon glyphicon-thumbs-up" ></i> Thanks for contacting us, we will get back to you shortly.
</div>
<div class="form-group">
<label class="col-md-3 control-label"></label>
<div class="col-md-6">
<button type="submit" class="btn btn-warning" > Submit <span class="glyphicon glyphicon-send"></span></button>
</div>
</div>
、 Node-ExpressのPOSTアクション?
var router = express.Router();
router.post('/', function(req, res, next) {
const data = {
fname: req.body.name,
lname: req.body.lname,
...
comment: req.body.comment
}
// insert data using SQL/MongoDB library
// refresh same page if success, the input elements cleared
// and show the success alert or fail alert div in rendered HTML
res.render('contact', {
fname : ''
lname : ''
...
comment : ''
});
});
これはjQueryなしでも可能ですか?私はjQueryを使用しないことを好みます。