View Full Version : Checkbox Form Validation Help...
Doug89
04-22-2006, 08:46 PM
Hello all, i have been working on the JS form validation for my Order Page and i have tried a ton of different scripts to validate a checkbox (it is one of those "I agree to the terms and conditions blah blah blah") but i cant get it to work. I have even googled it and tried some ones online but they just wont go, any suggestions? Thanks! :D
Doug89
04-22-2006, 11:48 PM
Nevermind, i finally got it, the alert box was after the Return statement, silly me :P
Doug89
04-23-2006, 04:15 AM
Ok after some more tweaking and such i think it is done (except for the actual merchandise being in the shopping cart).
If you want to test out the submit form try it!
It wont be a real order, just some testing to make sure i worked out all the bugs :)
Click here to test it! (http://www.dalyphotography.com/order_checkout.htm)
Thanks! :D
¥åßßå
04-23-2006, 05:05 AM
Your form fails if js is disabled. You need to implement server side checks as well ;)
¥
00_heaven
04-23-2006, 10:52 AM
im going to review the site as a whole
1. i think the layout is great the colours work well with the whole site.
2. i love your logo but im not quite sure about the writing in the top left. It just seems as you have added a few filters on photoshop with fancy text
3.With the form i found it very annoying that once i didnt complete all the fileds and agreed to the terms and conditions then pressed submit about 9 diffreent alert boxes came up one after another. Im sure what you are trying to achieve is easily achieveable with php, and looks ab it more proffesional.
the alert box only worked well with the terms and conditions one
Or you could do like the invision board does it.
http://www.globalmuonline.com/forum/
check the registration form that they have here, pretty neet aint it?
(i cant directly link it, but click "register" button then check couple times "yes yes" so you can see the actual register form)
EDIT: Uses AJAX, might not be that easy to implement, but what can i say, next one ill do, will have one of those :)
Doug89
04-23-2006, 12:56 PM
Ill reverse the order of the Agree checkbox thingy...So that the 9 boxes will pop up before the You have not agreed to our ....
And i suppose ill try the form validation in PHP as well...
Doug89
04-23-2006, 03:09 PM
Ok, well i got it to work... A bit :(
I am having just one problem, how do i pass whether the Agree checkbox is checked or not to the PHP program?
I have tried many things (like if the box is checked, give another hidden field a value and pass that into the PHP) but i cant get it to go. Other than that it works fine.
Doesnt look too great, but at least now i have server and client side validation. ;)
Thanks if anyone could give me help! :D
change
<input type="checkbox" name="termsagree" id="termsagree" value="">
to
<input type="checkbox" name="termsagree" id="termsagree" value="checked">
then in php
if (isset($_POST['termsagree']) =="checked") {
echo "checked";
}
Doug89
04-23-2006, 11:39 PM
But if i do that isnt it automatically checked? I need the value to equal "Checked" when the user actually checks the box. If i set it like that it will be checked (at least to the PHP function) no matter if the user clicked it or not right?
It works as i put it.
$_POST['termsagree'] variable is only set when you check the checkbox.
So i just checked if the variable is set and value is correct.
Doug89
04-24-2006, 04:13 PM
Ok thanks! Ill try it out and let you guys know how it turns out :)
Doug89
04-24-2006, 04:25 PM
Awesome, it works great, thanks alot! :D
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.