Validators and javascript

Discussion in 'ASP .Net' started by dmedina, Jun 30, 2003.

  1. dmedina

    dmedina Guest

    How I can from client javascript know when one of my
    textboxes, Radio Button List, drop down box, etc...
    Validated to False when submitting the form.

    I can get the page_Isvalid==false but i need to know which
    control is empty or not selected, so i can put the
    cursor...

    //Sample code
    if (page_Isvalid==false){
    if (txt_box1.value.length<1){
    document.GetElementById('txt_box1').Focus()
    }
    }

    The code above works great but I don't now how to approach
    when i have a dropdownbox, radioButton list, etc...


    Thanks,
    dmedina
     
    dmedina, Jun 30, 2003
    #1
    1. Advertising

  2. The way I do the DropDownList boxes is I have the selected item say
    something like "make a selection" and it has a value of 0 (none of my other
    values have a 0 value.) that value is hardcoded as part of the list. Yes I
    did have to override the asp DropDownListBox to have this functionality, but
    you could also do it by hand.

    Then I step through it the same way you did with the TextBox except for the
    list box.

    if ( ddl_box1.value == "0" )
    document.GetElementById( 'ddl_box1').focus()

    HTH,

    bill

    "dmedina" <> wrote in message
    news:258601c33f26$fe2a5480$...
    > How I can from client javascript know when one of my
    > textboxes, Radio Button List, drop down box, etc...
    > Validated to False when submitting the form.
    >
    > I can get the page_Isvalid==false but i need to know which
    > control is empty or not selected, so i can put the
    > cursor...
    >
    > //Sample code
    > if (page_Isvalid==false){
    > if (txt_box1.value.length<1){
    > document.GetElementById('txt_box1').Focus()
    > }
    > }
    >
    > The code above works great but I don't now how to approach
    > when i have a dropdownbox, radioButton list, etc...
    >
    >
    > Thanks,
    > dmedina
     
    William F. Robertson, Jr., Jun 30, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ratman
    Replies:
    0
    Views:
    678
    Ratman
    Sep 14, 2004
  2. Nathan Sokalski
    Replies:
    4
    Views:
    4,493
    Nathan Sokalski
    Feb 11, 2008
  3. Nathan Sokalski

    Validators and JavaScript

    Nathan Sokalski, Sep 27, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    315
    bruce barker
    Sep 28, 2008
  4. Nathan Sokalski

    Client-Side Validation with Validators and JavaScript

    Nathan Sokalski, Feb 11, 2008, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    939
    Nathan Sokalski
    Feb 11, 2008
  5. Nathan Sokalski

    Validators and JavaScript

    Nathan Sokalski, Sep 27, 2008, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    124
    bruce barker
    Sep 28, 2008
Loading...

Share This Page