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.
Code:
<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
Else
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
Next
If Trim(strMessage) = "" Then
Call frmPRAP.Submit()
Else
Alert strMessage
Call objComment.Focus()
End If
</script>
Anyone have any ideals on this
Thanks
Jonsey