Click here to Skip to main content
15,894,720 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have textbox inside the grid in all modules. i want, when user enters more than 6 digit in the textbox,it should not allow to enter more than 6 digit in java script. that java script should call from script file.
Posted
Updated 29-Mar-14 1:58am
v3
Comments
OriginalGriff 29-Mar-14 6:14am    
And?
What have you tried?
Where are you stuck?

Use the maxLength=6 attribute.
E.g. <input type="text" style="width:100px;" maxlength="6" />
 
Share this answer
 
Comments
kamalsekhar 29-Mar-14 6:19am    
Hi,
I dont want like this. i want using java script. I want to write java script function in Java script folder and call in java script function into particular textbox
Abhinav S 29-Mar-14 6:24am    
http://www.w3schools.com/js/tryit.asp?filename=tryjs_lengthvalidate
try this.. :)

JavaScript
function isValidateLen(txtID)
{
txtObj = document.getElementById(txtID);
if(txtObj.value.length < 6)
{
return true;
}
else
{
return false;
}
}


ASP.NET
<asp:textbox id="txtBox" runat="server" width="150px" onkeypress="javascript:return isValidateLen(this);" xmlns:asp="#unknown"> </asp:textbox>
 
Share this answer
 
Comments
kamalsekhar 29-Mar-14 6:59am    
Hi Nirav,

I have so many text box in all modules. i dont want to take textbox id. i want to wrtie java script inside the javascript folder and should call the function in each textbox
Nirav Prabtani 29-Mar-14 7:52am    
just put in all textbox onkeypress="javascript:return isValidateLen(this);" it will work

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