html form --> vbscript

  • Thread starter Thread starter nathalia
  • Start date Start date
N

nathalia

Hello,
I think i want a simple thing but don't know how to fix it.

I have a html form and i want to check if people didn't left any
fields blank. If they leave it black i want to show a message and stay
on the same page. I can show the message but it always go's to the
page i have put in mijn "action" of the html form.

Here is the code;

<form name="enquete" method="post" action="resultaten.asp">

<select name="keuze">
<option value="leeg">maak een keuze</option>
<option>via een andere website</option>
<option>via school</option>
<option>via vrienden familie</option>
<option>op een andere manier</option>
</select>


<select name="mening">
<option value="start">maak een keuze</option>
<option>Leuk</option>
<option>Gaat wel</option>
<option>Niet leuk</option>
</select>


<textarea name="paramtext" cols="100" rows=5
collumns=50></textarea>

<input type="reset" name="leegmaken" value="reset">
<input type="submit" name="verzend" value="verzenden">

</form>


<script language="VBScript">
<!--
Sub verzend_OnClick()
If (document.enquete.keuze.Value = "leeg") Or
(document.enquete.mening.Value ="start") Or
(document.enquete.paramtext.value="") then
Msgbox "u heeft geen antwoord gegeven op alle vragen"
//now my program may not send the form result because there
are not any
End If
End Sub
-->
</script>



thanks in advance
greets nathalia
 
nathalia said:
Hello,
I think i want a simple thing but don't know how to fix it.

I have a html form and i want to check if people didn't left any
fields blank. If they leave it black i want to show a message and
stay on the same page. I can show the message but it always go's to
the page i have put in mijn "action" of the html form.

Here is the code;

The question has no relation to VB.NET. I think it is better placed in a
VBScript (or an ASP.NET?) group.
 
Hi Nathalia,

This may not be the official method but it woprks for me.

Change your submit button to an ordinary button.
<input type="submit" name="verzend" value="verzenden">
becomes
<input type="button" name="verzend" value="verzenden">

Then use this

Sub verzend_OnClick()
If (document.enquete.keuze.Value = "leeg") Or
(document.enquete.mening.Value ="start") Or
(document.enquete.paramtext.value="") then
Msgbox "u heeft geen antwoord gegeven op alle vragen"
'now my program may not send the form result because there are not any
values
Else
'now my program <will> send the form
document.enquete.submit
End If
End Sub

In other words your OnClick will do the submit only if the fields have
been given a value.

Regards,
Fergus
 
(e-mail address removed) (nathalia) scripsit:
I have a html form and i want to check if people didn't left any
fields blank. If they leave it black i want to show a message and stay
on the same page. I can show the message but it always go's to the
page i have put in mijn "action" of the html form.

Notice that this is a VB.NET language group, but your question is
related to VBScript programming:

You may want to ask the question in this group:

<
 
Back
Top