0
요약 : 드롭 다운 메뉴로 선택하지 않은 경우 오류 메시지를 설정하려고합니다.자바 스크립트에서 레이블 텍스트 설정
세부 사항 :
가 여기에 자바 스크립트 함수를 호출 내 DD입니다 : 여기
<script type="text/javascript">
$(document).on("blur", "select[name=TypeId]",
function errorCheck() {
var errId = 'Type not chosen. Please choose from the menu.';
if (document.getElementById('TypeId').selectedIndex == 0) {
document.getElementById("DetailsError").visibility = 'visible';
document.getElementById("DetailsError").innerHTML = errId;
}
});
</script>
내가 값을 변경하려면 레이블의 : 여기
<%:Html.DropDownListFor(r => Model.TypeId, TypeItems, new { @class="stretchInput", @onblur = "errorCheck"})%>
나의 자바 스크립트입니다 :
<td><asp:Label ID="DetailsError" runat="server" CssClass="errorMsg" Text="testing" Visible="false"></asp:Label></td>
그건 그렇고 ASP 컨트롤이라고 알고 있습니다. 난 HTML label
시도하고 동일한 결과가 얻을.
모두 내 오류 메시지로 레이블의 텍스트를 설정하려고합니다. 내가하는 일은 어떤 식 으로든 라벨에 영향을 미치지 않는 것으로 보입니다.
무엇이 누락 되었습니까?
페이지의 생성 된 소스를보고 레이블을 찾으십시오. 너 뭐가 보이니? – epascarello
테스트 – user2284341
빙고! 나는 'MainContent_'로 DetailsError의 접두사를 붙였습니다. 감사합니다 epascarello! – user2284341