Click here to Skip to main content
15,896,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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!!
Posted
Comments
anushripatil 21-Dec-11 0:03am    
u can use an alert
[no name] 21-Dec-11 0:06am    
Can u suggest me to how to display that alert!! I don't no how to write java script for that!!

you can write in this way :

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

in script tag :
JavaScript
<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. :)
 
Share this answer
 
Comments
[no name] 21-Dec-11 0:50am    
Thank you so much!! It's working!!
add this script

JavaScript
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

HTML
onchange='validate(this)'
 
Share this answer
 
v2
Comments
Karthik Harve 21-Dec-11 0:14am    
[Edit] pre tags added.
[no name] 21-Dec-11 0:25am    
where i can declare this (onchange='validate(this)')
Tanveer A 22-Dec-11 0:48am    
<asp:TextBox id="txt" runat="server" onchage="validate(this);"/>
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
 
Share this answer
 
there is one more method to do this..please use your range validation control using java script and there is a textbox property name Onblur() or OnTextChange().you can code on this event.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900