View Single Post
  #1 (permalink)  
Old July 25th, 2004, 06:37 AM
mar0364 mar0364 is offline
Authorized User
 
Join Date: Jul 2003
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validation Question

Just starting to really get into hand coded form validation.

I have this bit of code that does a fairly good job. I just want to make the phone number validation so that people can use a hyphen when they type a phone number. Can anyone show me how or help me with it.I would also like to control the date range for the dates. Say it would only take a date before or after a specific date.


Code:
<script language=vbscript>
Sub btnSubmit_OnClick()
    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
    ElseIf Len(honotice.txthomephone.value) <2 or Not IsNumeric(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
</script>



Thanks!


Reply With Quote