Guest_imported
New member
- Jan 1, 1970
- 0
Anybody knows how to write client side vbscript? I need to check if the required fields are filled when the submit button of a HTML form is clicked. Lets say the name of the submit button is btnSubmit. I wrote something like this:
Sub btnSubmit_onClick()
If Len(field1.value) = 0 then
alert "Please fill in field1"
form.field1.focus
ElseIf Len(field2.value) = 0 Then
alert "Please fill in field2"
form.field2.focus
......
End If
End Sub
When I click the submit button, an alert box pops up for the first missing field. But after I click OK, it submits the form to the server instead of setting focus back on the missing field.
Any help is appreciated.
Sub btnSubmit_onClick()
If Len(field1.value) = 0 then
alert "Please fill in field1"
form.field1.focus
ElseIf Len(field2.value) = 0 Then
alert "Please fill in field2"
form.field2.focus
......
End If
End Sub
When I click the submit button, an alert box pops up for the first missing field. But after I click OK, it submits the form to the server instead of setting focus back on the missing field.
Any help is appreciated.