Hey,
Something like this:
Sub btnSubmit_OnClick()
Dim objregx
set objregx = New RegExp
objregx.pattern = "(1-)?\d{3,}-\d{3,}-\d{4,}"
If isdate(honotice.txtlossdate.value) = 0 Then
Alert "You must enter a loss date. If you do not know the loss date please call 1-800-000-0000"
honotice.txtlossdate.focus
Exit Sub
ElseIf Len(honotice.txtinsuredname.value) <2 or IsNumeric(honotice.txtinsuredname.value)then
Alert "You must enter the insured. If you do not know the insured name please call 1-800-000-0000"
honotice.txtinsuredname.focus
Exit Sub
ElseIf Len(honotice.txtpolicynumber.value) = 0 Then
Alert "You must enter the policy number. If you do not know the policy number please call 1-800-000-0000"
honotice.txtpolicynumber.focus
Exit Sub
ElseIf isdate(honotice.txtpolicyeffectdate.value) = 0 Then
Alert "You must enter a policy effective date. If you do not know the policy effective date please call 1-800-000-0000"
honotice.txtpolicyeffectdate.focus
Exit Sub
'Was just if, that is incorrect, and adjusted. By the way, vbscript also doesn't use alert,
'use msgbox; was alert working for you?
elseif (objRegx.test(honotice.txthomephone.value)) then
Alert "You must enter a phone number. If you do not have a phone please call 1-800-000-0000"
honotice.txthomephone.focus
Exit Sub
End If
Call honotice.submit()
End Sub
Found two errors, look for the comment above. In addition, you can remove the exit subs and put the Call honotice.submit() in the last routine if you want it to run whenever none of the other conditions are met. Just reduces some code for you.
elseif (objRegx.test(honotice.txthomephone.value)) then
Alert "You must enter a phone number. If you do not have a phone please call 1-800-000-0000"
honotice.txthomephone.focus
else
Call honotice.submit()
End If
|