Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Customvalidator, javascript and focus()

Customvalidator, javascript and focus()

Scheduled Pinned Locked Moved Web Development
javascripttutorialquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    Uncle Monkey
    wrote on last edited by
    #1

    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

    U 1 Reply Last reply
    0
    • U 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

      U Offline
      U Offline
      Uncle Monkey
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups