반응형
사용자 지정 검증자 클라이언트 측에 대한 동적 오류 메시지
나는 검증을 위해 자바스크립트 함수를 호출하기 위해 사용자 정의 검증기를 사용하고 있습니다.제 문제는 오류 메시지를 동적으로 변경할 수 있어야 한다는 것입니다.코드는 다음과 같습니다.
<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="fcnValid1"
ErrorMessage="" Display="None" ValidateEmptyText="True">
</asp:CustomValidator>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="List" ShowMessageBox="True" ShowSummary="False" />
function fcnValid(source, args) {
var Status = document.getElementById("<%=ddlStatus.ClientID%>").value
if (Status == "In Underwriting") {
if (document.getElementById("<%=txtRequestor.ClientID%>").value == "") {
//sender.errormessage = "Test1"
//sender.innerHTML = "Test2";
document.getElementById("<%=txtRequestor.ClientID%>").focus();
args.IsValid = false;
}
}
}
유효성 확인 Javascript에서 메시지에 액세스하여 메시지를 변경할 수 있습니다.source
:
source.errormessage = "custom message here";
SO에서 다음 질문을 발견했습니다. 자세한 정보도 제공해야 합니다.
클라이언트에서 CustomValidator 컨트롤에 대한 오류 메시지를 다시 작성하려면 어떻게 해야 합니까?
well source.error 메시지가 제대로 작동하지 않았습니다.
source.innerText="오류 메시지"를 사용하는 것이 좋습니다.
source.errormessage = "custom message here";
언급URL : https://stackoverflow.com/questions/5394861/dynamic-error-message-for-custom-validator-clientside
반응형
'programing' 카테고리의 다른 글
윈도우즈에서 ssh-agent와 함께 git 사용 (0) | 2023.08.14 |
---|---|
동적으로 생성된 요소에 날짜 선택기() 배치 - JQuery/JQueryUI (0) | 2023.08.14 |
UI 레이블 높이를 동적으로 계산하는 방법은 무엇입니까? (0) | 2023.08.14 |
Fusionauth가 자동 모드로 전환 중 (0) | 2023.08.14 |
절대 위치 및 오버플로 숨김 (0) | 2023.08.14 |