![](/img/trans.png)
[英]How to check if the selected value of drop-down is set to No and Text-Box is blank using JavaScript
[英]How to set the focus to a text-box using javascript
我正在尝试使用JavaScript将焦点设置在文本框上,但是当我用其他语言运行时,它没有在文本框上设置焦点,因此对我不起作用。 我在这里做错了什么?
<script type="text/javascript">
function validate() {
var sleepQuality = document.getElementById('<%=txtRate.ClientID %>').value;
if (sleepQuality == "") {
alert("Please enter something....... ");
return false;
document.getElementById('<%=txtRate.ClientID %>').focus();
}
}
</script>
Return退出功能。 执行完之后什么都没有。
alert("Please enter something....... ");
return false;
document.getElementById('<%=txtRate.ClientID %>').focus(); //<-- I will not run
之前移动
alert("Please enter something....... ");
document.getElementById('<%=txtRate.ClientID %>').focus(); //<-- I will run
return false;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.