Sup everyone, I need a little bit of help here. This is in my current php code. Here's my current Expiration code for Credit Card Form posting. Its a drop down menu defaulting like the following : Exp: [09] [2008] and then customer chooses expiration. Exp: <select name="p_cardexmo"><script language="javascript"> var m = new Date().getMonth()+1; for (i = 1; i <= 12; i++) document.write("<option value=\"" + i + "\"" + (i==m?' selected':'') + ">" + i + "</option>\n"); </script></select> / <select name="p_cardexyr"><script language="javascript"> var y = new Date().getFullYear(); for (i = 0; i <= 10; i++) document.write("<option value=\"" + (y+i) + "\">" + (y+i) + "</option>\n"); </script> PHP: But the problem is my site has some customers who leave it as the default which for this month is 09/2008 cause it is set to default and forget to select their credit card expiration. I need a better way of accepting this expiration date so that this doesn't happen. Anyone have a current one for expiration i can use ? Thanks in advance and help would be great.
how about adding a blank <option value="">---</option> in front (just after <select>) and add form validation code to ask them to choose a date if they leave it blank. or just let them type the month and year themselves.
how do you add a form validation code? i'm not too sure how. i'm still learning but can you show me how the complete code would look using the option value. Thanks adshelp
if you wan before-submit validation, you will need javascript. do a search on google : javascript form validation (i am sorry i am not allowed to post links) you will find a lot of informations there. You can do after-submit validation using PHP by making the adding a name="" to the <input type="submit" /> <input name="submit" type="submit" /> Code (markup): and the php part (just an example) if (isset( $_POST['submit']) ) { // form validation if ($POST['creditcardwhat'] == '') { // what you want to do if the field is empty } } else { // display form } PHP: