public string LengthCheck(string pw) { if (Request.IsAjaxRequest()) { bool status = PasswordUtility.PasswordLength(pw); string result = status ? "通過" : "不通過"; return(result); } else { return("非AJAX請求!"); } }
//合適用 AJAX public string LengthCheck(string pw) { if (Request.IsAjaxRequest()) { bool status = PasswordUtility.PasswordLength(pw); string result = status ? "通過" : "不通過"; return(result); } else { return("非 AJAX 請求 !"); } //前端需搭配 // <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script> }