表单验证,自定义提示内容
XML/HTML Code
- <div class="row">
- <div class="col-md-offset-3 col-md-6 col-sm-offset-2 col-sm-8">
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">Registration</h3>
- </div>
- <div class="panel-body">
- <form class="form-horizontal" action="." id="form1">
- <div class="form-group">
- <div class="col-lg-12"><label class="control-label" for="username">Username</label></div>
- <div class="col-lg-12">
- <input type="text" name="username" id="username" class="form-control really-simple required"
- data-required-message="Your username must be not blank"
- data-really-simple-message="Please enter a valid username, it should contain only letters and numbers" />
- </div>
- </div>
- <div class="form-group">
- <div class="col-lg-12"><label class="control-label" for="name">Name</label></div>
- <div class="col-lg-12">
- <input type="text" name="name" id="name" class="form-control required"
- data-required-message="Your name must be not blank" />
- </div>
- </div>
- <div class="form-group">
- <div class="col-lg-12"><label class="control-label" for="password">Password</label></div>
- <div class="col-lg-12">
- <input type="password" name="password" id="password" class="form-control password required"
- data-required-message="Your password must be not blank"
- data-password-message="Please enter a valid password, it should contain at least 6 characters with at least 1 number and special character" />
- </div>
- </div>
- <div class="form-group">
- <div class="col-lg-12"><label class="control-label" for="repassword">Confirm Password</label></div>
- <div class="col-lg-12">
- <input type="password" name="repassword" id="repassword" class="form-control repassword required"
- data-required-message="Confirm password must be not blank"
- data-repassword-message="Confirm password is not matched" />
- </div>
- </div>
- <div class="form-group">
- <div class="col-lg-12"><label class="control-label" for="email">Email</label></div>
- <div class="col-lg-12">
- <input type="text" name="email" id="email" class="form-control email required"
- data-required-message="Your email must be not blank"
- data-email-message="Your email must be like someone@somewhere.com" />
- </div>
- </div>
- <div class="form-group">
- <div class="col-lg-12"><label class="control-label" for="age">Age</label></div>
- <div class="col-lg-12">
- <input type="text" name="age" id="age" class="form-control number required"
- data-required-message="Your age must be not blank"
- data-number-message="Your age must be digits" />
- </div>
- </div>
- <div class="form-group">
- <div class="col-lg-12"><label class="control-label" for="dob">DOB</label></div>
- <div class="col-lg-12">
- <input type="text" name="dob" id="dob" class="form-control date required"
- data-required-message="Your DOB must be not blank"
- data-date-message="Your DOB must be like 14/02/2000" />
- </div>
- </div>
- <hr />
- <div class="form-group">
- <div class="col-lg-12"><label class="control-label" for="website">Website link</label></div>
- <div class="col-lg-12">
- <input type="text" name="website" id="website" class="form-control url required"
- data-required-message="Your website must be not blank"
- data-url-message="Your website must be like www.somewhere.com" />
- </div>
- </div>
- <div class="form-group">
- <div class="col-lg-12"><label class="control-label" for="websiteName">Website name</label></div>
- <div class="col-lg-12">
- <input type="text" name="websiteName" id="websiteName" class="form-control simple required"
- data-required-message="Your website name must be not blank"
- data-simple-message="Your website name must contains only letters, numbers and only 1 underscore or dash or space between letters and numbers" />
- </div>
- </div>
- <div class="form-group">
- <div class="col-lg-12"><label class="control-label" for="websiteColor">Website main color</label></div>
- <div class="col-lg-12">
- <input type="text" name="websiteColor" id="websiteColor" class="form-control regex required"
- data-regex="^#?([a-f0-9]{6}|[a-f0-9]{3})$"
- data-required-message="Your website main color must be not blank"
- data-regex-message="Your website main color must be like #000 or #000000" />
- </div>
- </div>
- <hr />
- <div class="form-action">
- </div>
- </form>
- </div>
- </div>
- </div>
- </div>
原文地址:http://www.freejs.net/article_biaodan_826.html