Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > html form validation

Reply
Thread Tools

html form validation

 
 
Shailesh
Guest
Posts: n/a
 
      09-13-2004
Hello,

I am new to this group and I have a simple question about an html form. I
have a check box field for user to select if they agree with my terms. Then
click on submit button. I want a message box appear, if a user has not
selected the check box field when click on submit button. Could someone help
me with that code? Thank you in advance.

Sam


 
Reply With Quote
 
 
 
 
Mark Parnell
Guest
Posts: n/a
 
      09-13-2004
On Mon, 13 Sep 2004 04:22:44 GMT, Shailesh <(E-Mail Removed)>
declared in alt.html:

> Hello,


G'day.

> I am new to this group


We all were once.

> and I have a simple question about an html form. I
> have a check box field for user to select if they agree with my terms. Then
> click on submit button. I want a message box appear, if a user has not
> selected the check box field when click on submit button. Could someone help
> me with that code? Thank you in advance.


If you want a message box to pop up as soon as they try to submit the
form, you will need to use Javascript. I can't help you much there,
though others no doubt can.

If you want to show an error page (which you should do anyway in case
client-side scripting is disabled/unavailable), you need to check
whether the checkbox is selected in your form handler. How to do that
depends on what language the form handler is written in.

--
Mark Parnell
http://www.clarkecomputers.com.au
"Never drink rum&coke whilst reading usenet" - rf 2004
 
Reply With Quote
 
 
 
 
Leif K-Brooks
Guest
Posts: n/a
 
      09-13-2004
Shailesh wrote:
> I am new to this group and I have a simple question about an html form. I
> have a check box field for user to select if they agree with my terms. Then
> click on submit button. I want a message box appear, if a user has not
> selected the check box field when click on submit button. Could someone help
> me with that code? Thank you in advance.


This should work, but make sure to also check it server-side:

<script type="text/javascript">
function validate_checkbox() {
var checkbox = document.getElementById('checkbox');
if (!checkbox.checked) {
alert("The check box must be checked.");
return false;
} else {
return true;
}
}
</script>
<form action="foo.html" onsubmit="return validate_checkbox()">
<p><label for="checkbox">Check this:</label>
<input type="checkbox" id="checkbox"></p>
<p><input type="submit" value="Submit"></p>
</form>
 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      09-13-2004
"Shailesh" <(E-Mail Removed)> wrote:

> I have a check box field for user to select if they agree with my
> terms. Then click on submit button. I want a message box appear, if a
> user has not selected the check box field when click on submit
> button.


Don't bother. It won't have the legal impact that clueless authors
assume. If your lawyer has said otherwise, ask him to cite a court
decision that is relevant. (Spoiler: ur jba'g, orpnhfr ur pna'g, ohg lbh
znl rawbl gur ireony qvneeurn cerfragrq vafgrnq.)

It's just an annoyance, and people either go elsewhere after the
disruption, or check the box without reading your terms, and without
committing themselves to them.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


 
Reply With Quote
 
Sam Hughes
Guest
Posts: n/a
 
      09-14-2004
"Jukka K. Korpela" <(E-Mail Removed)> wrote in
news:Xns95635C2AC1D84jkorpelacstutfi@193.229.0.31:

> (Spoiler: ur jba'g, orpnhfr ur pna'g, ohg lbh
> znl rawbl gur ireony qvneeurn cerfragrq vafgrnq.)


Nice cipher puzzle Answer re-encrypted with ROT-26 for the ROT-13-
clueless...
he won't, because he can't, but you
may enjoy the verbal diarrhea presented instead.

 
Reply With Quote
 
Neal
Guest
Posts: n/a
 
      09-14-2004
On 14 Sep 2004 06:26:03 GMT, Sam Hughes <(E-Mail Removed)> wrote:

> "Jukka K. Korpela" <(E-Mail Removed)> wrote in
> news:Xns95635C2AC1D84jkorpelacstutfi@193.229.0.31:
>
>> (Spoiler: ur jba'g, orpnhfr ur pna'g, ohg lbh
>> znl rawbl gur ireony qvneeurn cerfragrq vafgrnq.)

>
> Nice cipher puzzle Answer re-encrypted with ROT-26 for the ROT-13-
> clueless...
> (snip)


Thanks, that ROT-26 is so much easier to decipher...
 
Reply With Quote
 
Shailesh
Guest
Posts: n/a
 
      09-14-2004
Thanks for the reply. The form handler is written in HTML? (not sure) using
MS FrontPage.



"Mark Parnell" <(E-Mail Removed)> wrote in message
news:1hy87d9mw4lsl$(E-Mail Removed).. .
> On Mon, 13 Sep 2004 04:22:44 GMT, Shailesh <(E-Mail Removed)>
> declared in alt.html:
>
> > Hello,

>
> G'day.
>
> > I am new to this group

>
> We all were once.
>
> > and I have a simple question about an html form. I
> > have a check box field for user to select if they agree with my terms.

Then
> > click on submit button. I want a message box appear, if a user has not
> > selected the check box field when click on submit button. Could someone

help
> > me with that code? Thank you in advance.

>
> If you want a message box to pop up as soon as they try to submit the
> form, you will need to use Javascript. I can't help you much there,
> though others no doubt can.
>
> If you want to show an error page (which you should do anyway in case
> client-side scripting is disabled/unavailable), you need to check
> whether the checkbox is selected in your form handler. How to do that
> depends on what language the form handler is written in.
>
> --
> Mark Parnell
> http://www.clarkecomputers.com.au
> "Never drink rum&coke whilst reading usenet" - rf 2004



 
Reply With Quote
 
Shailesh
Guest
Posts: n/a
 
      09-14-2004
Thanks for your help. I will certainly try the javascript you have provided.


"Leif K-Brooks" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Shailesh wrote:
> > I am new to this group and I have a simple question about an html form.

I
> > have a check box field for user to select if they agree with my terms.

Then
> > click on submit button. I want a message box appear, if a user has not
> > selected the check box field when click on submit button. Could someone

help
> > me with that code? Thank you in advance.

>
> This should work, but make sure to also check it server-side:
>
> <script type="text/javascript">
> function validate_checkbox() {
> var checkbox = document.getElementById('checkbox');
> if (!checkbox.checked) {
> alert("The check box must be checked.");
> return false;
> } else {
> return true;
> }
> }
> </script>
> <form action="foo.html" onsubmit="return validate_checkbox()">
> <p><label for="checkbox">Check this:</label>
> <input type="checkbox" id="checkbox"></p>
> <p><input type="submit" value="Submit"></p>
> </form>



 
Reply With Quote
 
Mark Parnell
Guest
Posts: n/a
 
      09-15-2004
On Tue, 14 Sep 2004 17:13:25 GMT, Shailesh <(E-Mail Removed)>
declared in alt.html:

> Thanks for the reply. The form handler is written in HTML? (not sure) using
> MS FrontPage.


No, HTML cannot actually _do_ anything. It simply describes the
structure of the content of your page. The form handler is whatever is
in the action="" attribute of your <form>. If you didn't write it, then
you will need to consult the documentation, or contact the person who
did write it.

BTW: Please don't post upside down.
http://www.allmyfaqs.com/faq.pl?How_to_post
http://en.wikipedia.org/wiki/Top-posting

This will help:
http://home.in.tum.de/~jain/software/oe-quotefix/

--
Mark Parnell
http://www.clarkecomputers.com.au
"Never drink rum&coke whilst reading usenet" - rf 2004
 
Reply With Quote
 
selvamgt selvamgt is offline
Junior Member
Join Date: Oct 2007
Posts: 1
 
      10-25-2007
Hi,

I have a question in HTML form.
I have multiple checkbox field. I want a message to be appear for each and every checkbox field if the user has not selected the checkbox field when click on submit button.
Can you pls tell me how to validate multiple checkbox in HTML form.

Regards,
Selvam
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A form validation library with javascript validation Grigory Temchenko Python 0 12-28-2008 08:38 PM
string validation/ form validation OriginalBrownster Python 1 08-21-2006 01:50 AM
Struts validation for combine form fields validation Sumith Mathur Java 0 09-23-2004 06:26 PM
Form Validation Problem...Persisiting form fields on validation failure. bnp Javascript 4 05-12-2004 12:16 PM
Web form validation vs object validation Colin Basterfield ASP .Net 1 11-29-2003 12:10 AM



Advertisments