Splatcat Posted June 12, 2005 Posted June 12, 2005 Hi, Does anyone know hhow to make the "comments box" on the "checkout_payment.php" page a compulsory field for filling in data. I would like to make it so that you cannot click the continue button unless you have first filled in any information in the box. If you have not filled in any information then you will be propted to do so. Thanks in advance
avoisin Posted June 13, 2005 Posted June 13, 2005 Hi, Does anyone know hhow to make the "comments box" on the "checkout_payment.php" page a compulsory field for filling in data. I would like to make it so that you cannot click the continue button unless you have first filled in any information in the box. If you have not filled in any information then you will be propted to do so. Thanks in advance <{POST_SNAPBACK}> There's lots of ways to do it, but the majority of the time that I want to "require" a field on a form, such as this one, I use Javascript to check for a blank field. Some people strictly hate javascript, but it's ideal for this situation. You could do more strict checking on the destination page, but a quick javascript check is probably all you want. I like to use this code a lot: function isEmpty(inputStr) { var len= inputStr.length; if (len==0) return true; //else var p=0; var ch=""; while (p<len) { ch= inputStr.charAt(p); if (('A'<=ch && ch<='Z') || ('a'<=ch && ch<='z') || ('0'<=ch && ch<='9')) return false; p++; } return true; } in the header and then function CheckFields() { if (isEmpty(document.Request.firstname.value)) { alert("Please supply your first name"); document.Request.firstname.focus(); return; } document.Request.submit(); } somewhere, then have the form creation call say: <form action="submit.php" method="POST" name="Request" onSubmit="CheckFields();return(false);">
Splatcat Posted June 15, 2005 Author Posted June 15, 2005 Thanks for your help but, either i am doin it wrong or the code is wrong. It is more likely that i am inputting the code wrongly. I must say that i am a complete novice at this and any extra help would be greatly apreciated. Thanks
avoisin Posted June 15, 2005 Posted June 15, 2005 Thanks for your help but, either i am doin it wrong or the code is wrong. It is more likely that i am inputting the code wrongly. I must say that i am a complete novice at this and any extra help would be greatly apreciated. Thanks <{POST_SNAPBACK}> well .... let's start with this - is the javascript-type solution i'm describing what you're looking for?
Splatcat Posted June 15, 2005 Author Posted June 15, 2005 yep that is great. I am mostly unsure about the way in which you intergrate the check into the submit button as it is a link to the next page using a php confirmation image. But as i said, i'm an exteem novice when it comes to this. my experiance of php is "weeks" old. thanks
Splatcat Posted June 17, 2005 Author Posted June 17, 2005 The code supplied works. Just took me some time to learn how to input it. Hope this helps others too. Stu
avoisin Posted June 17, 2005 Posted June 17, 2005 The code supplied works. Just took me some time to learn how to input it. Hope this helps others too. Stu <{POST_SNAPBACK}> Glad to hear it helped ... I was going to do the full code for you, but I've been burning the midnight oil on my latest firmware rev at my other job ;) Scott
Recommended Posts
Archived
This topic is now archived and is closed to further replies.