C# 코드
protected void cusCustom_ServerValidate(object sender, ServerValidateEventArgs e)
{
if(e.Value.Length == 8)
e.IsValid = true;
else
e.IsValid = false;
}
페이지 코드
<asp:CustomValidator runat="server" id="cusCustom" controltovalidate="txtoedate" onservervalidate="cusCustom_ServerValidate" errormessage="The text must be exactly 8 characters long!" />
위의 코드는 길이를 위해 일하고,하지만 난이 같은 날짜 형식을 확인하려면 "yyyy-mm-dd",이 날짜 형식 확인, 내 코드 변경 방법.
이
오, 아니요, 날짜를 확인하기 위해'시도 ... 잡아 두지 마세요. 'DateTime.TryParseExact'를 사용하십시오. –
샘플 코드 – Gopal
@ 다린을 얻을 수 있습니까? TryParse 만 알 수 있었지만 TryParseExact는 알지 못했습니다. 감사. –