如何显示弹出消息! [英] How to display Popup Message!

查看:79
本文介绍了如何显示弹出消息!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用范围验证控件,在我的文本框中仅接受10个以下的数字,如果我们在该文本框中输入任何其他数字,则需要显示弹出消息(错误消息).如果我们输入其他任何数字,例如11,12. .然后我们可以显示弹出消息msg,(``Ols输入10个数字以下'').

可以使用弹出消息吗?

救救我吧!

Hi,

I am using range validation control, in my text boxes accepts only below 10 numbers, If we enter any other numbers in that text box i need to display popup message (Error Message).If we enter any other numbers like 11,12...then we can display popup msg ,(''Ols enter below 10 numbers'').

It is possible to use popup message ?

Help me!!

推荐答案

您可以这样写:

< asp:textbox id ="text1" runat ="server" onkeypress =返回isNumeric();" xmlns:asp =#unknown">

在脚本标签中:
you can write in this way :

<asp:textbox id="text1" runat="server" onkeypress="return isNumeric();" xmlns:asp="#unknown">

in script tag :
<script type="text/javascript">
function isNumeric() {
var num= parseInt(document.getElementById("<%=text1.ClientID %>").value);
          if (num >10) {
              alert("Please enter valid number.");
              return false;
          }
return true;
}
</script>



希望对您有帮助.
如果有帮助,请不要忘记将其标记为答案. :)



Hope this will help you.
And don''t forget to mark this as answer if it helps. :)


添加此脚本

add this script

function validate(ctr)
{
try
{
var txt=document.getElementById(elementid).value;
if (parseInt(txt)>10)
{
alert('Number Should Be Less than 10');

}
}
catch(Error)
{
alert(Error);
}
}


将此脚本添加到文本框中


add this script into textbox

onchange='validate(this)'


尊敬的Murali,

在这里您可以使用客户端脚本,即javascirpt警报框.您可以将文本框clientID作为参数发送到javascirpt函数,在其中可以测试其中包含的ID值大于10的文本,然后可以显示相同的警报框.

请将此标记为对您有帮助的答案.

谢谢
Dear Murali,

Here you can go for Client scripting i.e., javascirpt alert box. You can send the textbox clientID as parameter to your javascirpt function where you can test that the text contained in it that id it has value greater than 10 then an alert box for the same can be showed.

Please mark this as your answer of it helps you.

Thanks


这篇关于如何显示弹出消息!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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