js pug 代码_前端开发nodejs+pug——注册登录
extends layout
block opration-content
a(class=”nav-item nav-link”href=”/login”)Login
a(class=”nav-item nav-link active”href=”#”)SignUp
block content
.login.row.justify-content-md-center
.col-md-8
.card.border-secondary
.card-headerRegister
.card-body.text-secondary
form(οnsubmit=”return false;”)
.form-group.row
lable(for=”name”class=”col-sm-4 text-right”)Name
.col-sm-6
input(
type=”text”
name=”name”
class=”form-control”
id=”name”
placeholder=”Name”
required
)
.form-group.row
lable(for=”sex”class=”col-sm-4 text-right”)Sex
.col-sm-6
label.custom-control.custom-radio
input(
id=”radioStacked1″
name=”sex”
type=”radio”
value=”0″
class=”custom-control-input”
required
)
span.custom-control-indicator
span.custom-control-descriptionMale
label.custom-control.custom-radio
input(
id=”radioStacked2″
name=”sex”
type=”radio”
value=”1″
class=”custom-control-input”
required
)
span.custom-control-indicator
span.custom-control-descriptionFemale
.form-group.row
lable(for=”address”class=”col-sm-4 text-right”)Address
.col-sm-6
input(
type=”text”
name=”address”
class=”form-control”
id=”address”
placeholder=”Address”
required
)
.form-group.row
lable(for=”password”class=”col-sm-4 text-right”)Password
.col-sm-6
input(
type=”password”
name=”password”
class=”form-control”
id=”password”
placeholder=”Password”
required
)
.form-group.row
lable(for=”password_confirmation”class=”col-sm-4 text-right”)ConfirmPassword
.col-sm-6
input(
type=”password”
name=”password_confirmation”
class=”form-control”
id=”password_confirmation”
placeholder=”Confirm Password”
required
)
.form-group.row
lable.col-sm-4.text-right驗證碼
#captcha.col-sm-6
p#wait.show正在加載驗證碼……
.row
.col-sm-8.ml-sm-auto
button(type=”submit”class=”btn btn-dark”id=”registerBtn”)
i(class=”fa fa-sign-in”aria-hidden=”true”)
|SignUp
append header
script(src=CommonLibs+’/js/gt.js’)
script.
functionregister(captchaObj){
var result = captchaObj.getValidate();
if(!result){
returnalert(‘請完成驗證’);
}
var name =$(‘input[name=name]’).val();
var pwd =$(‘input[name=password]’).val();
var cpwd =$(‘input[name=password_confirmation]’).val();
var sex =$(‘input[name=sex]:checked’).val();
var address =$(‘input[name=address]’).val();
var udate =newDate();
if(name ==”|| pwd ==”|| cpwd ==”|| sex ==”|| address ==”){
returnfalse;
}
udate = udate.Format(‘yyyy-MM-dd hh:mm:ss’);
if($.md5(pwd)!= $.md5(cpwd)){
alert(‘The confirmation password is not identical.’);
returnfalse;
}
var param ={
uname: name,
upwd: $.md5(pwd),
usex: sex,
uaddress: address,
udate: udate
};
$.ajax({
type:’post’,
url:’/ghost/register’,
data: param,
dataType:’json’,
success:function(res){
alert(‘Register Success’);
window.location.href =’/login’;
},
error:function(err){
console.log(err);
captchaObj.reset();
}
});
returnfalse;
}
varhandler=function(captchaObj){
captchaObj.appendTo(‘#captcha’);
captchaObj.onReady(function () {
$(“#wait”).hide();
});
$(‘#registerBtn’).click(function(){
register(captchaObj);
});
// 更多接口說明請參見:http://docs.geetest.com/install/client/
window.gt= captchaObj;
};
$.ajax({
url:”gt/register-slide?t=”+(newDate()).getTime(),// 加隨機數防止緩存
type:”get”,
dataType:”json”,
success:function(data){
// 調用 initGeetest 進行初始化
// 參數1:配置參數
// 參數2:回調,回調的第一個參數驗證碼對象,之后可以使用它調用相應的接口
initGeetest({
// 以下 4 個配置參數為必須,不能缺少
gt: data.gt,
challenge: data.challenge,
offline:!data.success,// 表示用戶后臺檢測極驗服務器是否宕機
new_captcha: data.new_captcha,// 用于宕機時表示是新驗證碼的宕機
product:”float”,// 產品形式,包括:float,popup
width:”100%”
// 更多配置參數說明請參見:http://docs.geetest.com/install/client/
}, handler);
}
});
// 對Date的擴展,將 Date 轉化為指定格式的String
// 月(M)、日(d)、小時(h)、分(m)、秒(s)、季度(q) 可以用 1-2 個占位符,
// 年(y)可以用 1-4 個占位符,毫秒(S)只能用 1 個占位符(是 1-3 位的數字)
// 例子:
// (new Date()).Format(“yyyy-MM-dd hh:mm:ss.S”) ==> 2006-07-02 08:09:04.423
// (new Date()).Format(“yyyy-M-d h:m:s.S”) ==> 2006-7-2 8:9:4.18
Date.prototype.Format=function(fmt){//author: meizz
var o ={
“M+”:this.getMonth()+1,//月份
“d+”:this.getDate(),//日
“h+”:this.getHours(),//小時
“m+”:this.getMinutes(),//分
“s+”:this.getSeconds(),//秒
“q+”:Math.floor((this.getMonth()+3)/3),//季度
“S”:this.getMilliseconds()//毫秒
};
if(/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1,(this.getFullYear()+””).substr(4-RegExp.$1.length));
for(var k in o)
if(newRegExp(“(“+ k +”)”).test(fmt)) fmt = fmt.replace(RegExp.$1,(RegExp.$1.length==1)?(o[k]):((“00″+ o[k]).substr((“”+ o[k]).length)));
return fmt;
總結
以上是生活随笔為你收集整理的js pug 代码_前端开发nodejs+pug——注册登录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php.exe不是 32位有效应用程序,
- 下一篇: Pug