获取验证码
<div class="randcode">
<label for="">验证码:</label> <input class="txt-area" type="text"
name="RandCode" id="RandCode" /> <input id="randcode_btn"
class="btn" type="button" value="获取验证码" onclick="_code();" />
<span id="code-span"> <i id="code_error_icon"
class="error_icon" style=" left:383px;top: 250px;display: none;"></i> <span
name="code_error" class="bus_error"></span></span>
</div>
var yzm = '';
function _code() {
//if (check2()) {
$('#randcode_btn').unbind('click');
$('#randcode_btn').attr('disabled', 'disabled');
$('#randcode_btn').val('120');
var i = 120;
var sto = function() {
if (--i > 0) {
$('#randcode_btn').val(i + '');
setTimeout(sto, 1000);
} else {
$('#randcode_btn').val('获取验证码');
$('#randcode_btn').removeAttr('disabled');//变亮
$('#randcode_btn').bind('click', _code);//重复事件
}
}
setTimeout(sto, 1000);
var phone = $('#tel_phone').val();
var CertType = $("input[name='document_type']:checked").val();
$.ajax({
url : '/sms',
type : 'post',
data : {
phone : phone,
certType : CertType
},
dataType : 'json',
success : function(data) {
var message = decodeURI(data.message);
yzm = decodeURI(data.yzm);
// console.debug(message);
if (message)
alert(message + '验证码:' + yzm);
},
error : function() {
alert('error');
}
});
//}
}