JQ 获取当前的cookie信息 并做判断
function getCookie(cookieName){
var cookieValue="";
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
if (cookie.substring(0, cookieName.length + 2).trim() == cookieName.trim() + "=") {
cookieValue = cookie.substring(cookieName.length + 2, cookie.length);
break;
}
}
}
return cookieValue;
}
然后判断
$("button").on("click",function(){
var skey = getCookie("mobile_code");
if($("#mobile_code").val() !=skey){alert("验证码不正确!");return false;}
})