javascript - Why does my java script function stop half way without reason -
please note page school project, not meant function payment page. code executes on submit, gets far checking name, if there problem date or cvc code skips , continues if received true value. great deadline approaching. need run entirety of code. example of code it can found @ http://www.come-get-me-games.x11s.org/confirm_booking.php
the code area is
<script type="text/javascript"> function check(){ var num = document.getelementbyid('cardnumber'); var name = document.getelementbyid('nameoncard'); var dater = document.getelementbyid('expdate'); var cvc = document.getelementbyid('cvc'); if(num.value==="" || num.value===null){ alert('please enter card number'); return false; }else if (name.value==="" || name.value===null){ alert('please enter appears on card'); return false; }else if (dater.value==="dd/mm/yyy" || dater.value === "" || dater.value===null){ alert('please enter date'); return false; }else if (cvc.value==="" || cvc.value===null){ alert('enter cvc number, can found \n last 3 digits on number on of code'); return false; } else { var check = confirm('are sure wish purchase these tickets'); if(check === true){ return true; }else{ return false; } } } </script> </table> </div> <div style="text-align:left;position:absolute;bottom:0px;left:10px;width:480px"> <?php echo "total ticket price £".$price ?><br> <br> <h3>payment</h3> <form method="post" action="scripts/ticket_buy.php" onsubmit="return check()"> <div class="item_container"> card number <input value="" type="text" id="cardnumber" name="cardnumber" style="position:absolute;right:0px" /><br /> name on card<input value="" type="text" id="nameoncard" style="position:absolute;right:0px" name="nameoncard" /><br /> expiry date<input value="" type="date" id="epxdate" style="position:absolute;right:0px" name="expdate" /><br /> cvc number<input value="" type="text" id="cvc" style="position:absolute;right:0px" name="cvc"> <br /> <input type="hidden" value='<?php echo $eventidwanted ?>' name="eid"> <input type="hidden" value="<?php echo $performanceidwanted ?>" name="pid"> <input type="submit" value="purchase" class="button_default" style="width:480px"> </div> </form> </div>
correct id date. in js have expdate while in input have epxdate
expiry date<input value="" type="date" id="expdate" style="position:absolute;right:0px" name="expdate" /><br />
working jsfiddle
just note : whenever js seems not working use firebug console or chrome console see if there js error or not.
Comments
Post a Comment