Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate controls Client Side 2

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
US
I have 2 ComboBoxes that I want to make sure have text when the user clicks on the continue button. I want to do this client side. I have

If document.thisForm.cboEngSerNo.Text = "" then
Msgbox("You have not selected an Engine!")
ElseIf document.thisForm.cboTrnSerNo.Text = "" Then
MsgBox("You have not selected a Transmission!")
End If

I get the first MsgBox, but I can't figure out how to get the second? Rob
Just my $.02.
 
you should use the "value" parameter for your option list

your script should read:
If document.form1.cboEngSerNo.value = "" then
Msgbox("You have not selected an Engine!")
ElseIf document.form1.cboTrnSerNo.value = "" Then
MsgBox("You have not selected a Transmission!")
End If

and your options should read should read:
<select name=&quot;cboEngSerNo&quot;>
<option value=&quot;&quot;></option>
<option value=&quot;engine1&quot;>engine1</option>
<option value=&quot;engine2&quot;>engine2</option>
</select>
 
I tried that just now after reading your post, but I got the same results. It will catch the first one but not the second. The trouble is that they can be left blank. I just want to remind the user that they have not selected one, the other, or both. When the MsgBox for the Engine is clicked OK I want the Transmission message to be displayed also, even if an Engine is not choosen.

Hope this makes sense? Rob
Just my $.02.
 
If you want the second message to display even if the first is displayed, then you can't put them in a single if... elseif statement. Split them into two:

If document.thisForm.cboEngSerNo.Text = &quot;&quot; then
Msgbox(&quot;You have not selected an Engine!&quot;)
end if
If document.thisForm.cboTrnSerNo.Text = &quot;&quot; Then
MsgBox(&quot;You have not selected a Transmission!&quot;)
End If
 
JuanitaC,
That is exactly what I needed. Works like a charm. Thanks so much. Rob
Just my $.02.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top