1,RequiredFieldValidator:非空校验
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) { int month = Convert.ToInt32(txtMonth.Text); int day = Convert.ToInt32(txtDay.Text); int[] data ={ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int days = data[month-1]; args.IsValid=(day <= days && day >= 1); }
<script type="text/javascript"> function dayVaild(src,args) { var txtMonth = document.getElementById("<%=txtMonth.ClientID %>"); var month = parseInt(txtMonth.value, 10) var day = parseInt(args.value, 10) var data = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; var days = data[month - 1]; args.IsValid = (day <= days && day >= 1); } </script>
原文:http://www.cnblogs.com/blackHorseplan/p/3887455.html