var offtime;
var vodTime = 3;
var phonevalidationcode = ".phonevalidationcode";

$(document).ready(function () {
    $(phonevalidationcode).removeAttr("disabled");
    $(phonevalidationcode).attr("dov", vodTime);
    $(phonevalidationcode).click(function () {

        $.ajax({
            url: "/api/message/sms_validation.ashx",
            data: { phone: $("input[name='uMobile_Card']").val(), posttype: $("input[name='posttype']").val() },
            dataType: "json",
            success: function (call) {
                if (call.Code != 200) {
                    alert(call.Msg)
                    return;
                } else {
                    $(phonevalidationcode).attr("disabled", "disabled");
                    $(phonevalidationcode).val($(phonevalidationcode).attr("dov") + "秒后重发");
                    offtime = setInterval('setText()', 1000);
                    alert(call.Msg)
                }
            }
        })



    })



});
function setText() {
    var self = $(phonevalidationcode);
    var max_data = self.attr("dov");
    if (max_data < 2) {
        $(phonevalidationcode).val("获取");
        $(phonevalidationcode).attr("dov", vodTime);
        clearInterval(offtime);
        $(phonevalidationcode).removeAttr("disabled");
    } else {
        max_data = max_data - 1;
        $(phonevalidationcode).val(max_data + "秒后重发");
        $(phonevalidationcode).attr("dov", max_data);
    }
}