HTML JS Form pre-submission detection data

Source: Internet
Author: User
Tags button type

Control whether data is submitted by using the Onsibmit of the form

The return values are true commits, others are unchanged, examples are as follows:

JS section

function Check () {varNewpwd = document.getElementById ("newpwd"); varConfirmnewpwd = document.getElementById ("confirmnewpwd"); if(Newpwd.value = =confirmnewpwd.value)return true; Else {                        varErr = document.getElementById ("errmsg"); Err.style.display=""; return false; }                }

Html

<form action="/student/updatepwd"onsubmit="return check ()"> <divclass="Control-group"> <labelclass="Control-label"  for="Basicinput"> Old password </label> <divclass="Controls"> <input placeholder="Please enter ..."data-original-title="" class="span8 Tip"Type="Password"Name="oldpwd"Id="oldpwd"> </div> </div> <divclass="Control-group"> <labelclass="Control-label"  for="Basicinput"> New Password </label> <divclass="Controls"> <input placeholder="Please enter ..."data-original-title="" class="span8 Tip"Type="Password"Name="newpwd"Id="newpwd"> <spanclass="Help-inline"style="Color:red;display:none"Id="errmsg"> two times password inconsistency </span> </div> </div> <divclass="Control-group"> <labelclass="Control-label"  for="Basicinput"> re-enter new password </label> <divclass="Controls"> <input placeholder="Please enter ..."data-original-title="" class="span8 Tip"Type="Password"Id="confirmnewpwd"> </div> </div> <divclass="Control-group"> <divclass="Controls"> <button type="Submit" class="Btn-inverse Btn-large"> Updates </button> </div> </div> </form>

HTML JS Form pre-submission detection data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.