Giant Validation in ASP.Net
How to restrict user to only input INTEGER Values within 1 to 100 only, in textbox ??? if a user enter's value >100 or <0, textbox must be cleared .... if he enter <= 100 then proceed .. please reply fast
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhay ShankerPosted Feb 10, 2014, 11:52 PM
1.By using Range Validator
MinimumValue="0" MaximumValue="100" ControlToValidate="txtSalary"
ErrorMessage="Value must be a whole number between 0 and 100" />
2.Add a javascript on Keydown of TextBox
function CheckMax()
{
var num=document.getElementById('<%=txtSalary.ClientID %>').value ;
if (num >100 || num <=0)
{
alert('Please Enter Value between 1 to 100');
document.getElementById('<%=txtSalary.ClientID %>').value = '';
document.getElementById('<%=txtSalary.ClientID %>').focus();
return false;
}
return true;
}
Ramesh RPosted Feb 10, 2014, 12:42 PM