如果第一个数字是0,我们怎么能无法进入。阅读下面的细节: [英] How can we unable to entry if first number is 0. Read Below for the detail :
本文介绍了如果第一个数字是0,我们怎么能无法进入。阅读下面的细节:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果第一个数字 <,我们如何无法输入 span class =code-digit> 0 在文本框中。例如:
如果有人输入:
a) 000000000 - 不接受
b) 0000001 - 接受
b) 0000001002 - 接受
b) 0 - 不接受
如果有人有想法,请与我分享。
解决方案
< blockquote>文本框的OnBlur调用javascript函数说''fnCheckInput''。
function fnCheckInput( )
{
// 将其解析为intger。如果该值仅包含0,那么它将变为0.
var controlValue = document .getElementById(' TextBox1')。value;
var s = parseInt (controlValue);
// 如果值为0
if (s == 0 )
{
document .getElementById(' TextBox1')。value = ; // 设置空文本到文本框
返回 false ;
}
返回 true ;
}
这是你的HTML:
< asp:textbox id = TextBox1 < span class =code-attribute> runat = server onblur = return fnCheckInput(); xmlns:asp = #unknown > < / asp:textbox >
还有,哟你需要确保只在TextBox中输入数字。使用一些验证控件。
--Amit
试试这个
if (Convert.ToDouble(TextBox1.Text)== 0 )
{
// validation
}
谢谢
我已经解决了这个问题。这是一个小任务!
int idd = Convert.ToInt16(hour_value.text);
int p = 0 ;
if (idd > p)
{
}
其他
{
}
How can we unable to entry if first number is 0 in textbox. For example :
If anyone enters :
a) 000000000 - not accept
b) 0000001 - accept
b) 0000001002 - accept
b) 0 - not accept
If any one have an idea kindly share to me.
解决方案
OnBlur of the Textbox call a javascript function say ''fnCheckInput''.
function fnCheckInput() { //Parse it to intger. If the value contains only 0's in that then it'll become 0. var controlValue = document.getElementById('TextBox1').value; var s = parseInt(controlValue); //If the value is 0 if(s == 0) { document.getElementById('TextBox1').value = "";//Set empty text to textbox return false; } return true; }
Here is your HTML:
<asp:textbox id="TextBox1" runat="server" onblur="return fnCheckInput();" xmlns:asp="#unknown"></asp:textbox>
And also, you need to ensure that only numbers should be entered in TextBox. Use some validation control for that.
--Amit
try this
if(Convert.ToDouble(TextBox1.Text)==0) { //validation }
Thanks
I have solved this. Its a minor task !
int idd = Convert.ToInt16(hour_value.text); int p = 0; if (idd > p) { } else { }
这篇关于如果第一个数字是0,我们怎么能无法进入。阅读下面的细节:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文