簡體   English   中英

使用帶有Spring框架休眠的引導程序來驗證表單

[英]validating a form using bootstrap with spring framework hibernate

所以我有這種形式,它需要驗證,我正在使用引導程序,但是現在我試圖使用休眠將值插入到我的數據庫中,但是它不允許我,因為它需要“必需的自動對焦”或“必需的”等號,我在引導程序上看不到任何文檔來驗證我的表單..我現在需要使用JavaScript來驗證我的表單嗎? 我希望有人可以幫助我,這是我的代碼

<c:url var="actionUrl" value="save" />
    <form:form id="registerForm" commandName="users" method="post" action="${actionUrl }" class="form-horizontal" >
        <fieldset>
        <div class="form-group">
            <label class="col-lg-2 control-label" for="email">Email</label>
            <div class="col-lg-10">
            <form:input path="email" class="form-control" placeholder="Email Address" type="email" required autofocus />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-2 control-label" for="username">Username</label>
            <div class="col-lg-10">
            <form:input path="username" class="form-control" placeholder="Username" type="username" required />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-2 control-label" for="password">Password</label>
            <div class="col-lg-10">
            <form:input path="password" class="form-control" placeholder="Password" type="password" required />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-2 control-label" for="location">Location</label>
            <div class="col-lg-10">
                <form:select path="location" class="form-control" type="location" >
                <option>France</option>
                <option>Amsterdam</option>
                <option>Philippines</option>
                <option>Others</option>
            </form:select>

            <form:input path="userId" type="hidden" />
            </div>
        </div>

        <div class="modal-footer">
            <button class="btn btn-primary" type="submit" id="register">Register</button>
            <button class="btn btn-default" data-dismiss="modal" type="button">Cancel</button> 
        </div><!-- end modal-footer -->
        </fieldset>
    </form:form>

只需為所有輸入字段添加<form:errors path="username" /> ,依此類推。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM