﻿$(document).ready(function() {
    $("#clear").click(function() {
        $("#no").val("");
        $("#phone").val("");
        $("#email").val("");
        $("#title").val("");
        $("#msg").val("");
        return false;


    })
    $("#anonymous").click(function() {

        if ($("#anonymous").attr("checked") == true) {
            $("#no").val("");
            $("#lno").text("你的姓名：");
        }
        else {
            $("#no").val("");
            $("#lno").text("读者学号：");
        }
        $("#no").focus();
    })
    $("#sendmsg").click(function() {

        if ($("#no").val() == "") {
            alert("请确认你输入的信息是否正确！");
            $("#no").focus();
            return false;
        }
        else {
            if (jQuery.trim($("#title").val()) == "") {
                alert("请输入留言标题！");
                $("#title").focus();
                return false;
            }
        }

    })
    $("#no").blur(function() {
        if ($("#anonymous").attr("checked") != true) {
            $.ajax({
                type: "GET",
                url: "getuid.aspx",
                dataType: "html",
                data: "uid=" + $("#no").val(),
                beforeSend: function(XMLHttpRequest) {
                },
                success: function(msg) {
                    //alert(msg);
                    if (msg == "0") {
                        var mm = $("#no").val();
                        $("#no").val("");
                        if (jQuery.trim(mm) != "") {
                            alert("学号 " + mm + " 不存在，请核对！");
                        }
                    }

                },
                complete: function(XMLHttpRequest, textStatus) {
                },
                error: function() {
                }
            });
        }
    })

})
