在javascript中没有页面重新加载的文本框值空检查。 [英] textbox value empty check without page reload in javascript.

查看:76
本文介绍了在javascript中没有页面重新加载的文本框值空检查。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如何在javascript中没有页面重新加载/刷新的文本框值空/空检查。



how to textbox value empty / null check without page reload/refreshing in javascript.

推荐答案

如何在没有页面重新加载/刷新的情况下将文本框值空/空检查

您需要引发任何客户端事件,以便您可以访问客户端上的控件在JavaScript中,然后检查控件中的值。



示例:

how to textbox value empty / null check without page reload/refreshing in javascript
You need any client side event raised such that you can access the control on client side in JavaScript and then check the value in control.

Example:
<input type="button" id="check" onclick="CheckValue();" />

<script>
//JS code
function CheckValue()
{
  // Access the control here
  // Check the value of the control and take appropriate action. 
}
</script>





试用。如果您遇到任何问题,请发布特定问题。



Try out. Post specific issue if you face any.


尝试从您的javascript函数返回false。使用像这样:

Try returning false from your javascript function. Use Like this:
funciton fnValidate()
{
     var txt = document.getElementById('TextBox1');
     if(txt.value == "")
     {
         return false;
     }
}



替代方式:

您可以尝试在TextBox中使用 RequiredFiedValidator 控制asp.net。





- 发送


Alternate Way:
You can try using RequiredFiedValidator control of asp.net in the TextBox.


--Amit


这篇关于在javascript中没有页面重新加载的文本框值空检查。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆