Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 21st, 2007, 07:55 AM
Authorized User
Join Date: Jan 2007
Location: , , USA.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jonsey Send a message via Yahoo to jonsey
Default Validation Radio Buttons

I have a script that works great to see what radio button is checked and then looks to see if comment is filled in for that question.

Now I just need to see if all answers are checked and if not give an alert and set.focus to that radio button.

Ok got it to work but keeps going to the first element.

 <script language="vbscript" for="btnSaveAudit" event="onclick"> 

    Dim strMessage, requiredComment, objComment

    For Each r In document.getElementsByTagName("input")

        If r.Type = "radio" Then 

            If Not r.Checked Then

            Set objComment = document.getElementsByName(r.Name)(0)
                    strMessage = strMessage & "Questions must have a Yes/No answer." & vbCrLf
                    Set requiredComment = r
                    Exit For


                If Not IsNull(r.Value) And r.Value <= 0 Then

                    Set objComment = document.getElementsByName(Replace(r.Name, "Value", "Comment"))(0)

                    If Len(objComment.Value) < 5 Then

                        strMessage = strMessage & "Questions answered with 'No' require a Comment." & vbCrLf
                        Set requiredComment = r
                        Exit For

                    End If

                End If

            End If

        End If


    If Trim(strMessage) = "" Then
        Call frmPRAP.Submit()
        Alert strMessage
        Call objComment.Focus()
    End If
Anyone have any ideals on this

Reply With Quote
  #2 (permalink)  
Old June 6th, 2007, 11:48 PM
Registered User
Join Date: Dec 2006
Location: Karachi, , Pakistan.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts

Actually, javascript can better be used to target this scenario

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Radio Buttons and Calculations Student101 Java Basics 4 June 21st, 2009 11:02 AM
validation in radio buttons MunishBhatia ASP.NET 2.0 Professional 5 December 11th, 2007 11:15 AM
Radio buttons disappear JoeBob49 ASP.NET 2.0 Basics 2 November 27th, 2006 09:57 AM
How to use the radio buttons? ben_VB VB.NET 2002/2003 Basics 1 January 18th, 2005 12:29 PM

All times are GMT -4. The time now is 08:09 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.