Customvalidator, javascript and focus()
-
I have a datagrid containing an EditItemTemplate column. The column contains a textbox and a customvalidator control. The ClientValidationFunction on the customvalidator is calling the javascript function correctly and I can check the value entered into the textbox ok, however if the validation fails I need to set the document focus back to the textbox 'tdValue'. Does anyone know how this can be done? The 'source.controltovalidate' javascript property will return me a value in the form - controlname_dgDatagridName__ctl3_tdValue but I do not know how to use this name value to call the tdValue.focus() method. Any suggestions? function CheckCurrency(source, arguments) { //Do my validation here alert(source.controltovalidate) } Thanks It ain't what you know that matters. Uncle Monkey
-
I have a datagrid containing an EditItemTemplate column. The column contains a textbox and a customvalidator control. The ClientValidationFunction on the customvalidator is calling the javascript function correctly and I can check the value entered into the textbox ok, however if the validation fails I need to set the document focus back to the textbox 'tdValue'. Does anyone know how this can be done? The 'source.controltovalidate' javascript property will return me a value in the form - controlname_dgDatagridName__ctl3_tdValue but I do not know how to use this name value to call the tdValue.focus() method. Any suggestions? function CheckCurrency(source, arguments) { //Do my validation here alert(source.controltovalidate) } Thanks It ain't what you know that matters. Uncle Monkey
Whoops heres the edititemtemplate that was supposed to be in the last message :P <edititemtemplate> <asp:textbox id="tdValue" runat="server" text='<%# DataBinder.Eval(Container.DataItem, "tdvalue", "{0:0.00}") %>' /> <asp:CustomValidator id="validate_tdValue" EnableClientScript="true" runat="server" ControlToValidate="tdValue" ErrorMessage="My Error" ClientValidationFunction="CheckCurrency" /> </edititemtemplate> It ain't what you know that matters. Uncle Monkey