Bootstrap实现登录校验表单(带验证码)

       这个登陆窗口是双登陆窗口的,对IE8及早期版本不支持,可以根据自己的开发语言更换,我这个是asp的,其中的引用文件可以在网络上自行下载,如找不到可以留下邮箱~!

Bootstrap实现登录校验表单(带验证码)_第1张图片

关键代码如下所示:

  1. http-equiv="Content-Type"content="text/html; charset=utf-8"/>
  2. </span><span class="pln">scm登陆界面</span><span class="tag">
  3. type="text/css">
  4. body {
  5. background-color:#999;
  6. }
  7. rel="stylesheet"href="../bootstrap335/css/bootstrap.min.css">
  8. rel="stylesheet"href="../bootstrap335/css/bootstrapValidator.min.css">
  9. src="../bootstrap335/js/jquery-2.1.4.min.js">
  10. src="../bootstrap335/js/bootstrap.min.js">
  11. src="../bootstrap335/js/bootstrapValidator.min.js">
  12. <% 
  13. Response.Buffer=True 
  14. Response.ExpiresAbsolute=Now()-1 
  15. Response.Expires=0 
  16. Response.CacheControl="no-cache" 
  17. %>
  18. >
  19. class="col-lg-5 col-lg-offset-2">
  20. class="page-header"style="margin-top:5em;">
  21. ******管理系统

  • class="col-md-offset-4 col-md-4">
  • class="panel panel-primary"style="margin-top:3em;">
  • id="myTab"class="nav nav-tabs">
  • class="active">href="#Prv"data-toggle="tab">供应商登陆
  • href="#CPrv"data-toggle="tab">生产商登陆
  • id="myTabContent"class="tab-content"> 
  • class="tab-pane fade in active"id="Prv">
  • class="well well-sm ">class="panel-title">
  • 供应商登陆
  • class="panel-body">
  • name="LoginG"id="LoginG"action="Admin_ChkLogin_G.asp"method="post"target="_parent">
  • class="form-group">
  • class="input-group">
  • class="input-group-addon">账号
  • name="Username"type="text"class="form-control"placeholder="Username">
  • />
  • class="form-group">
  • class="input-group">
  • class="input-group-addon">密码
  • name="Password"type="Password"class="form-control"placeholder="Password">
  •  
  •  
  • 请将如下计算结果填入文本框内:
  • class="form-group form-horizontal">
  • class="col-lg-3 control-label "id="captchaOperation">
  • class="col-lg-9">
  • type="text"class="form-control "name="captcha"/>
  • />/>/> 
  • class="form-group">
  • class="btn btn-primary btn-block"type="submit"value="登  录"/>
  • class="tab-pane fade"id="CPrv">
  • class="well well-sm">class="panel-title">
  • 生产商登陆
  • class="panel-body"> 
  • name="LoginS"id="LoginS"action="Admin_ChkLogin_S.asp"method="post"target="_parent">
  • class="form-group">
  • class="input-group">
  • class="input-group-addon">账号
  • name="Username2"type="text"class="form-control"placeholder="Username">
  • />
  • class="form-group">
  • class="input-group">
  • class="input-group-addon">密码
  • name="Password2"type="Password"class="form-control"placeholder="Password">
  •  
  •  
  • 请将如下计算结果填入文本框内:
  • class="form-group form-horizontal">
  • class="col-lg-3 control-label "id="captchaOperation2">
  • class="col-lg-9">
  • type="text"class="form-control "name="captcha2"/>
  • />/>/> 
  • class="form-group">
  • class="btn btn-primary btn-block"type="submit"value="登  录"/>
  •  
  • type="text/javascript">
  • $(document).ready(function(){
  • // Generate a simple captcha
  • function randomNumber(min, max){
  • returnMath.floor(Math.random()*(max - min +1)+ min);
  • };
  • function generateCaptcha(){
  • $('#captchaOperation').html([randomNumber(1,50),'+', randomNumber(1,50),'='].join(' '));
  • };
  • generateCaptcha();
  • $('#LoginG')
  • .bootstrapValidator({
  • //message: 'This value is not valid',
  • feedbackIcons:{
  • valid:'glyphicon glyphicon-ok',
  • invalid:'glyphicon glyphicon-remove',
  • validating:'glyphicon glyphicon-refresh'
  • },
  • fields:{
  • Username:{
  • message:'The username is not valid',
  • validators:{
  • notEmpty:{
  • message:'供货商账户不能为空'
  • },
  • stringLength:{
  • min:5,
  • max:10,
  • message:'供货商账号长度 5-10'
  • },
  • /*remote: {
  • url: 'remote.php',
  • message: 'The username is not available'
  • },*/
  • regexp:{
  • regexp:/^[a-zA-Z0-9_\.]+$/,
  • message:'只接受数字和字母 '
  • }
  • }
  • },
  • Password:{
  • validators:{
  • notEmpty:{
  • message:'密码不能为空'
  • }
  • }
  • },
  • captcha:{
  • validators:{
  • callback:{
  • message:'验证码错误',
  • callback:function(value, validator){
  • var items = $('#captchaOperation').html().split(' '), sum = parseInt(items[0])+ parseInt(items[2]);
  • return value == sum;
  • }
  • }
  • }
  • }
  • }
  • })
  • .on('error.form.bv',function(e){
  • var $form = $(e.target),
  • bootstrapValidator = $form.data('bootstrapValidator');
  • if(!bootstrapValidator.isValidField('captcha')){
  • // The captcha is not valid
  • // Regenerate the captcha
  • generateCaptcha();
  • }
  • });
  • });
  • type="text/javascript">
  • $(document).ready(function(){
  • // Generate a simple captcha
  • function randomNumber(min, max){
  • returnMath.floor(Math.random()*(max - min +1)+ min);
  • };
  • function generateCaptcha(){
  • $('#captchaOperation2').html([randomNumber(1,50),'+', randomNumber(1,50),'='].join(' '));
  • };
  • generateCaptcha();
  • $('#LoginS')
  • .bootstrapValidator({
  • //message: 'This value is not valid',
  • feedbackIcons:{
  • valid:'glyphicon glyphicon-ok',
  • invalid:'glyphicon glyphicon-remove',
  • validating:'glyphicon glyphicon-refresh'
  • },
  • fields:{
  • Username2:{
  • message:'The username is not valid',
  • validators:{
  • notEmpty:{
  • message:'供货商账户不能为空'
  • },
  • stringLength:{
  • min:5,
  • max:10,
  • message:'供货商账号长度 5-10'
  • },
  • /*remote: {
  • url: 'remote.php',
  • message: 'The username is not available'
  • },*/
  • regexp:{
  • regexp:/^[a-zA-Z0-9_\.]+$/,
  • message:'只接受数字和字母 '
  • }
  • }
  • },
  • Password2:{
  • validators:{
  • notEmpty:{
  • message:'密码不能为空'
  • }
  • }
  • },
  • captcha2:{
  • validators:{
  • callback:{
  • message:'验证码错误',
  • callback:function(value, validator){
  • var items = $('#captchaOperation2').html().split(' '), sum = parseInt(items[0])+ parseInt(items[2]);
  • return value == sum;
  • }
  • }
  • }
  • }
  • }
  • })
  • .on('error.form.bv',function(e){
  • var $form = $(e.target),
  • bootstrapValidator = $form.data('bootstrapValidator');
  • if(!bootstrapValidator.isValidField('captcha')){
  • // The captcha is not valid
  • // Regenerate the captcha
  • generateCaptcha();
  • }
  • });
  • });
  • 你可能感兴趣的:(python&nodejs)