I have a webdatagrid two template fields... textboxes.. when the user enters a value in the first one and then goes to the second one, I need to make sure the second value is not greater then the first value...
Can someone help with some client side script to do this?
If you continue to experience any issues please do not hesitate to contact me.
Sorry haven't gotten back to you.
Looking at your javascript code..
What field are you referring to in this line.
getElementsByTagName("input")[0].value
Daryl,
That should be the textbox in the first column, i.e. the first cell in the row.
Do you need any additional assistance with the sample?
Please let us know if you have any questions or concerns, we will be glad to assist you.
Hi,
I have had to change me code a bit, so your example doesn't work..
first template field..
<ig:TemplateDataField Key="ShelfPrice" Width="12%" CssClass="deInput"> <Header Text="* Shelf Price"></Header> <ItemTemplate> <asp:Label runat="server" ID="money1" Text="$" Width="5px"/> <asp:TextBox runat="server" ID="txtShelfPrice" MaxLength="10" Width="50px" CausesValidation="True" /> <asp:RequiredFieldValidator ID="rfv_txtShelfPrice" runat="server" ErrorMessage="* Required" SetFocusOnError="True" Display="Dynamic" ControlToValidate="txtShelfPrice" Font-Bold="True" ForeColor="#CC0000"></asp:RequiredFieldValidator> </ItemTemplate> </ig:TemplateDataField>
second template field..
<ig:TemplateDataField Key="BidPrice" Width="12%" > <Header Text="* Bid Price"></Header> <ItemTemplate> <asp:Label runat="server" ID="money2" Text="$" Width="5px" /> <asp:TextBox runat="server" ID="txtBidPrice" MaxLength="10" CssClass="deinput" Width="50px" CausesValidation="True" onchange="textboxTextChanged(this, event)" /> <asp:RequiredFieldValidator ID="rfv_txtBidPrice" runat="server" ErrorMessage="* Required" SetFocusOnError="True" Display="Dynamic" ControlToValidate="txtBidPrice" Font-Bold="True" ForeColor="#CC0000"></asp:RequiredFieldValidator> </ItemTemplate> </ig:TemplateDataField>
so this function..
function textboxTextChanged(sender, eventArgs) { if (sender.parentNode._object.get_row().get_cellByColumnKey("ShelfPrice").get_element().getElementsByTagName("txtShelfPrice")[0].value > sender.value) { alert('Bid Price cannot be greater than Shelf Price') eventArgs.set_cancel(true); } }
Doesn't return anything on "[0].value" even thought the textbox has a value (both have values)
Thank you for your response and for posting in our forum.
I have resolved the issue thanks.
I am checking about the progress of this issue. Please let me know if you need any further assistance on this.
Hello,
I am glad that this function is working for you. Please take in consideration that if the templated Item is modified and other elements are added, the function should be modified in order to select the actual element that the TextBox is rendered as.
You could even consider using a simplified approach as:
function textboxTextChanged(sender, eventArgs) {
if (parseInt(sender.parentNode.parentNode.firstChild.children[0].value) < parseInt(sender.value)) { sender.value = ""; } }
Some checks in the function for the first TextBoxValue are also in order, depending on your application specifications, like:firstTextBoxValue = parseInt(sender.parentNode._object.get_row().get_cellByColumnKey("TemplateField_0").get_element().getElementsByTagName("input")[0].value); if ((firstTextBoxValue == (undefined)) || isNaN(firstTextBoxValue) || (firstTextBoxValue < parseInt(sender.value))) { sender.value = ""; } }
I am really glad that you manage to resolve this issue. Please do not hesitate to contact us if you are still experiencing any issues with this matter.
You know, it might be the difference in the version of the control, between 13.1 and 12.2, but the line you suggested, blew up every time.
However the line below works fine...
if (sender.parentNode.parentElement._object.get_cellByColumnKey("TemplateField_0").get_element().getElementsByTagName("input")[0].value < sender.value) {
Did you actually run your sample and put entry in the textboxes?