由于在EJS中使用If-else语句,我的Bootstrap表单完全消失了

时间:2018-06-21 06:26:54

标签: node.js express ejs

<div class="row" style="margin: auto; max-width: 850;">
    <h1 style="text-align: center">User Registration</h1>
                   <!-- <div class="well well-sm"><strong><span class="glyphicon glyphicon-asterisk" style="color: red"></span>Required Field</strong></div>-->
   <form role="form" action="/users/addUser" method="POST">
    <div class="form-group">
    
        <div class="span6">
                    <div class="col-lg-4">
                                        <div class="form-group">
                                            <label for="InputEmail">Username</label>
                                            <div class="input-group">
                                                <input type="text" style="width: 180%" class="form-control" id="username" name="username" placeholder="username" required>
                                                
                                                <!--
                                                <span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
                                                -->
                                            </div>
                                        </div>
                    </div>
         </div>
        <div class="span6">
                    <div class="col-lg-4">
                                        <div class="form-group">
                                                <label for="InputEmail">Password</label>
                                                <div class="input-group">
                                                    <input type="password" style="width: 180%"  class="form-control"  id="password" name="password" placeholder="password" required>
                                                    <!--
                                                    <span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
                                                    -->
                                                </div>
                                            </div>
                    </div>
         </div>
                                <!--
                                <div class="form-group">
                                    <label for="InputMessage">Enter Message</label>
                                    <div class="input-group">
                                        <textarea name="InputMessage" id="InputMessage" class="form-control" rows="5" required></textarea>
                                        <span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
                                    </div>
                                </div>
                                
                                <input type="submit" name="submit" id="submit" value="Submit" class="btn btn-info float-xs-right">-->
                     
               
                <div class="col-lg-5 push-md-1">
                    <div class="col-md-12">
                        <% if(isRegistered) { %>
                        <div class="alert alert-success">
                            <strong><span class="glyphicon glyphicon-ok"></span> <%= msg %>.</strong>
                        </div>
                        <% } else { %>
                        <div class="alert alert-danger">
                            <span class="glyphicon glyphicon-remove"></span><strong> <%= msg %> </strong>
                        </div>
                        <% } %>
                    </div>
                </div>
              
           

  
                <br>
                <br>
                <br>
                <hr>
                <input type="submit" name="submit" id="submit" value="Submit" class="btn btn-info float-xs-right">
            </form>
            </div>

            

            
       

如上所示,如果我在EJS中使用“ If-else”语句,我的表单将消失,如果将其删除,我的表单将再次出现在浏览器中。

我想做的是创建一个注册页面,如果用户已经存在,则在浏览器的一角显示警告消息,提示“用户已存在”。顺便说一句,此警报消息来自我的数据库(Oracle 11g)。

0 个答案:

没有答案