473,396 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

textbox inside the datagrid using javascript

Hi,I am New To This .
I have to check the duplications of values entered in textbox which is placed inside the datagrid using javascript

.And the Number of textbox is not constant it is dynamically added can any one solve this
Jan 2 '08 #1
6 7328
Frinavale
9,735 Expert Mod 8TB
Hi,I am New To This .
I have to check the duplications of values entered in textbox which is placed inside the datagrid using javascript

.And the Number of textbox is not constant it is dynamically added can any one solve this
What have you tried so far to solve this problem?

-Frinny
Jan 2 '08 #2
Hi,I am New To This .
I have to check the duplications of values entered in textbox which is placed inside the datagrid using javascript

.And the Number of textbox is not constant it is dynamically added can any one solve this
Hi,
Two approaches.
1. Check the text entered in the textbox is numeric or not using the onblur event of the textbox. This would be something like this.
<asp:GridView ID="GridView1" runat="server">
.
.
<asp:TextBox ID="txtNo" runat="server" onblur="javascript:IsNumeric(this.value);"></asp:TextBox>
.
.
</asp:GridView>

2. Have a global javascript variable which will be concatenated with the id of the dynamically added textboxes.
Upon click of the submit button use this variable to get the id's and check for their value.

hope this suggestion would be useful..

With regards,
ram
Jan 2 '08 #3
Frinavale
9,735 Expert Mod 8TB
Hi,
Two approaches.
1. Check the text entered in the textbox is numeric or not using the onblur event of the textbox. This would be something like this.
<asp:GridView ID="GridView1" runat="server">
.
.
<asp:TextBox ID="txtNo" runat="server" onblur="javascript:IsNumeric(this.value);"></asp:TextBox>
.
.
</asp:GridView>

2. Have a global javascript variable which will be concatenated with the id of the dynamically added textboxes.
Upon click of the submit button use this variable to get the id's and check for their value.

hope this suggestion would be useful..

With regards,
ram
Could you also post your JavaScript.
(Please place your code snippets within [code] tags...see the posting guidelines for information on how to use these tags)

-Frinny
Jan 2 '08 #4
Could you also post your JavaScript.
(Please place your code snippets within [code] tags...see the posting guidelines for information on how to use these tags)

-Frinny
Expand|Select|Wrap|Line Numbers
  1. function IsNumeric(strString)
  2.    //  check for valid numeric strings    
  3.    {
  4.    var strValidChars = "0123456789.-";
  5.    var strChar;
  6.    var blnResult = true;
  7.  
  8.    if (strString.length == 0) return false;
  9.  
  10.    //  test strString consists of valid characters listed above
  11.    for (i = 0; i < strString.length && blnResult == true; i++)
  12.       {
  13.       strChar = strString.charAt(i);
  14.       if (strValidChars.indexOf(strChar) == -1)
  15.          {
  16.          blnResult = false;
  17.          }
  18.       }
  19.    return blnResult;
  20.    }
  21.  
Hope this was useful

With regards,
ram
Jan 2 '08 #5
Expand|Select|Wrap|Line Numbers
  1. function IsNumeric(strString)
  2.    //  check for valid numeric strings    
  3.    {
  4.    var strValidChars = "0123456789.-";
  5.    var strChar;
  6.    var blnResult = true;
  7.  
  8.    if (strString.length == 0) return false;
  9.  
  10.    //  test strString consists of valid characters listed above
  11.    for (i = 0; i < strString.length && blnResult == true; i++)
  12.       {
  13.       strChar = strString.charAt(i);
  14.       if (strValidChars.indexOf(strChar) == -1)
  15.          {
  16.          blnResult = false;
  17.          }
  18.       }
  19.    return blnResult;
  20.    }
  21.  
Hope this was useful

With regards,
ram


Consider my grid having many textbox.And the number of textbox is not always constant.Suppose if am entereing 'thescripts' in one textbox and the same also in another textbox ,it should throw error.

Kindly note the number of textbox in the grid is not constant.
I can do this in server side ,since i want to do this in Jvascript kindy help me.
Jan 3 '08 #6
Frinavale
9,735 Expert Mod 8TB
Consider my grid having many textbox.And the number of textbox is not always constant.Suppose if am entereing 'thescripts' in one textbox and the same also in another textbox ,it should throw error.

Kindly note the number of textbox in the grid is not constant.
I can do this in server side ,since i want to do this in Jvascript kindy help me.
You're still going to need to do this check Server Side because it's easy to get around JavaScript validations.

Anyways...there's a way to grab all the input fields using JavaScript...from there you can loop through and check if the name matches the textboxes in your GridView:

Expand|Select|Wrap|Line Numbers
  1.     var all = document.getElementsByTagName('input');
  2.     var len = all.length;
  3.     for(var i = 0; i < len; i++)
  4.    {
  5.        var temp = all[i];
  6.        //if this temp variable is one of the textboxes in your
  7.        //GridView...Do Something .....
  8.    }
-Frinny
Jan 3 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Manish | last post by:
Hey folks I am having a weird problem in ASP .Net. My page is in C#. I have a datagrid, which populates based on selection in drop down box on ASP page. This datagrid has template textbox colum in...
2
by: jm | last post by:
I have datagrid. Inside the template columms there is a textbox. It has an id. When the textbox wasn't inside the datagrid tags, I could reference with order_id.text = "some text" but all of a...
1
by: Irishmaninusa | last post by:
Hello Everyone, I have a datagrid and have used a text box as way to allow a user to edit items in the grid. My question for you is how is it possible to write code for the text change event of...
1
by: Simon | last post by:
Hi I have a datagrid with a TemplateColumn where I have put inside a TextBox without databinding with the data source. The TextBox is used to type a number for each row of the datagrid. I have...
2
by: rt | last post by:
hi iam looking for any javascript or vbscript to add sum all the textboxes present in the datagrid. and sum must come in another total textbox. this should fire when the user enter the numeric...
0
by: jason | last post by:
Hello everyone. I am trying to write some custom command events into a DataGrid. The command that is currently giving me trouble is an "Add" custom command in the footer of a template column. ...
2
by: rockdale | last post by:
Hi, All: I have a datagrid that embedded 3 textbox using TemplateColumn. When the user key in value in the first textbox, I need to check to see if this value is between the the values in other...
1
by: CindyH | last post by:
Hi I'm using vs.net 2003. I have a dropdownlist inside a datagrid. I would like to be able to select a value from the dropdownlist and then have a textbox which is also inside the datagrid filled...
5
by: venkateshcnpl | last post by:
Hi,I am New To This . I have to check the duplications of values entered in textbox which is placed inside the datagrid.And the Number of textbox is not constant it is dynamically added can any one...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.