Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-12-2013, 11:47 PM   PM User | #1
hasser964
New to the CF scene

 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
hasser964 is an unknown quantity at this point
Validating forms and this piece of code does not work. Could you please tell me why?

I am validating forms in JavaScript, and It's just not working. I have tried to figure it out myself, but I can't. The spaces between the forms are where the break tags are.

<form name = "check" >
First Name*:
<input type="text" name="First Name" maxlength="15"/>




Last Name*:
<input type="text" name="Last Name" maxlength="15"/>




Email*:
<input type="text" name="Email"/>




Contact Number:
<input type="text" name="contact number"/>




Message*:


<textarea name="Enquiries" rows="10" cols="50">
</textarea>





<input type="checkbox" name="pricing"> I would like to find out the pricing of a particular painting.</input>


<input type="checkbox"> I am asking a question.</input>



<input type="submit" name="Send" onClick = "check()"/>

</form>

<script type = "text/javscript">

function check(){
if(document.check.pricing.checked){
alert("OIIIIIII!");
}
else{
alert("not checked");
}
}

</script>


P.S.
If you know any good places to learn Javascript, please post them with your answer
hasser964 is offline   Reply With Quote
Old 02-13-2013, 01:16 AM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,454
Thanks: 0
Thanked 498 Times in 490 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Don't attach an onclick to the submit button. Use onsubmit on the form tag itself and have the JavaScript return true or false depending on whether or not the form should be submitted.

Don't use alert - it is intended only for debugging.

See the orange link in my signature for a series of several hundred JavaScript tutorials.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 12:40 AM.


Advertisement
Log in to turn off these ads.