Wrox Programmer Forums
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 21st, 2007, 07:55 AM
Authorized User
Join Date: Jan 2007
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

Old June 6th, 2007, 11:48 PM
Registered User
Join Date: Dec 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts

Actually, javascript can better be used to target this scenario


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

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