<script type="text/javascript">
$(document).ready(function() {
$("#<%=txtNumeric.ClientID %>").focusout(function() {
var textvalue = $("#<%=txtNumeric.ClientID %>").val();
if (!validateDecimal(textvalue))
return false;
else {
$(this).removeClass("focus");
return true;
}
});
});
function validateDecimal(value) {
var RE = new RegExp(/^\d\d*\.\d\d$/);
if (RE.test(value)) {
return true;
} else {
alert("Please Enter in XX.XX format !");
$(this).addClass("focus");// this keyword is not working here !!
$(this).focus(); // this keyword is not working here !!
return false;
}
}
</script>
어떻게 호출 된 함수에서 현재 ASP 텍스트 상자의 ID를 얻을 수 있습니까? bcuz이 작동하지 않습니다. 아무도 나를 도울 수 있습니까? 이jquery 함수에서 asp 텍스트 상자의 ID를 얻는 방법
$(document).ready(function() {
$("#<%=txtNumeric.ClientID %>").focusout(function() {
var textvalue = $("#<%=txtNumeric.ClientID %>").val();
if (!validateDecimal(textvalue,this))
return false;
else {
$(this).removeClass("focus");
return true;
}
});
});
function validateDecimal(value,ControlObject) {
var RE = new RegExp(/^\d\d*\.\d\d$/);
if (RE.test(value)) {
return true;
} else {
alert("Please Enter in XX.XX format !");
$(ControlObject).addClass("focus");// this keyword is not working here !!
$(ControlObject).focus(); // this keyword is not working here !!
return false;
}
}
왜 매개 변수로 전달하지 않습니까? –
클래스를 사용하여이를 사용하는 경향이 있으므로 클라이언트 코드와 서버 코드를 섞어서 사용하지 않아도됩니다. – RubbleFord