Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Comments Box


Splatcat

Recommended Posts

Posted

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

Posted
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

 

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);">




			
		
Posted

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

Posted
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

 

well .... let's start with this - is the javascript-type solution i'm describing what you're looking for?

Posted

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

Posted

The code supplied works. Just took me some time to learn how to input it.

 

Hope this helps others too.

 

Stu

Posted
The code supplied works. Just took me some time to learn how to input it.

 

Hope this helps others too.

 

Stu

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...