TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vamsidhar kotipalli
NA
59
5.4k
javascript in grid databound (code behind)
Sep 15 2014 11:50 AM
I have one text box in my grid and need to set validation like should allow numbers upto
3 digits only
validation should be done from code behind (grid row databound)
i have javascript its working fine .but i need same js in row data bound
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-CssClass="assignborder">
<headertemplate>Interval</headertemplate>
<itemtemplate><asp:TextBox ID="txtInterval" runat="server" onkeyup="validate()l"></asp:TextBox></itemtemplate>
</asp:TemplateField>
function validate()
{
//getting key code of pressed key
var keycode = (key.which) ? key.which : key.keyCode;
var intrval = document.getElementById('ctl00_Mdi_grdabc_txtInterval');
//comparing pressed keycodes
if (!(keycode==8 || keycode==46)&&(keycode < 48 || keycode > 57)) {
alert("Please Enter Digits only");
return false;
}
else
{
//Condition to check textbox contains 3 numbers or not
if (intrval.value.length < 3)
{
return true;
}
else
{
alert("Interval Should not be greater than 3 digits");
return false;
}
}
}
Reply
Answers (
5
)
Track last 5 or 10 visited products like shopping ites in as
How to check gridview last row textbox value in asp.net?