$(function () {
$('form').bootstrapValidator({
message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
linkman: {
message: '使用者名驗證失敗',
validators: {
notEmpty: {
message: '不能為空'
},
}
},
tel: {
validators: {
notEmpty: {
message: '電話号碼不能為空'
},
regexp: {
regexp: /^1\d{10}$/,
message: '手機号碼不正确,請重新輸入'
}
}
},
email: {
validators: {
notEmpty: {
message: '郵箱不能為空'
},
regexp: {
regexp: /^\[email protected]\w+(\.[a-zA-Z]{2,3}){1,2}$/,
message: 'Email格式不正确,例如[email protected]m'
}
}
},
talker_info: {
validators: {
notEmpty: {
message: '不能為空'
},
stringLength: {
min: 0,
max: 300,
message: '0/300個字元'
}
}
},
summary: {
validators: {
notEmpty: {
message: '不能為空'
},
stringLength: {
min: 0,
max: 300,
message: '0/300個字元'
}
}
},
field: {
validators: {
notEmpty: {
message: '不能為空'
},
stringLength: {
min: 0,
max: 300,
message: '0/100個字元'
}
}
},
account: {
validators: {
notEmpty: {
message: '不能為空'
},
stringLength: {
}
}
},
theme: {
validators: {
notEmpty: {
message: '不能為空'
},
stringLength: {
min: 0,
max: 50,
message: '0/50個字元'
}
}
},
act_time: {
validators: {
notEmpty: {
message: '不能為空'
}
}
},
address: {
validators: {
notEmpty: {
message: '不能為空'
}
}
},
title: {
validators: {
notEmpty: {
message: '不能為空'
}
}
},
}
})
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r != null) return unescape(r[2]);
return null;
}
// 調用方法
var ssid = GetQueryString("ssid");
$(".btn").click(function(){
var flag = $('#defaultForm').data("bootstrapValidator").isValid();//校驗合格
if(flag){
var $form = $('#defaultForm');
$.ajax({
type:"post",
url:"https://dev-api.yiketalks.com/v4/talker/talkerApply",
data:$("#defaultForm").serialize(),
headers: {
"Accept": "text/plain; charset=utf-8",
// "Content-Type": "text/plain; charset=utf-8",
"ssid": ssid
},
async:true,
success: function (result) {
$(".concentBox").css("display","none");
$('.jsrz_main_check').css("display","block");
}
});
}
});
});