Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Validators and javascript

Reply
Thread Tools

Validators and javascript

 
 
dmedina
Guest
Posts: n/a
 
      06-30-2003
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
 
Reply With Quote
 
 
 
 
William F. Robertson, Jr.
Guest
Posts: n/a
 
      06-30-2003
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" <(E-Mail Removed)> wrote in message
news:258601c33f26$fe2a5480$(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validators and JavaScript Nathan Sokalski ASP .Net Web Controls 1 09-27-2008 11:09 PM
Validators and JavaScript Nathan Sokalski ASP .Net 1 09-27-2008 11:09 PM
Client-Side Validation with Validators and JavaScript Nathan Sokalski ASP .Net Building Controls 4 02-11-2008 07:58 PM
Client-Side Validation with Validators and JavaScript Nathan Sokalski ASP .Net 4 02-11-2008 07:58 PM
Regular Expression validators NOT working, Required Field validators ARE working Ratman ASP .Net 0 09-14-2004 09:36 PM



Advertisments