VirtueMart Forum

VirtueMart 2 + 3 => General Questions => Topic started by: david.kwock on July 04, 2012, 08:08:57 am

Title: How to make the User comment text box as a Required field???
Post by: david.kwock on July 04, 2012, 08:08:57 am
Hello, :D

I am trying to add a Empty validation rule for the 'Leave comment' text-box on the check out page.
Which file should I look at to make it as a compulsory filed????

Thank you!!  :)

David
Title: Re: How to make the User comment text box as a Required field???
Post by: Milbo on July 04, 2012, 12:39:01 pm
FE/views/cart/tmpl/default.php
Title: Re: How to make the User comment text box as a Required field???
Post by: david.kwock on July 05, 2012, 05:14:41 am
Thank you, Milbo  :D

I have looked at the file and tried to insert form validation using this method displayed on: http://docs.joomla.org/Client-side_form_validation

Code: [Select]
<form method="post" id="checkoutForm" name="checkoutForm" action="<?php echo JRoute::_'index.php?option=com_virtuemart&view=cart'.$taskRoute,$this->useXHTML,$this->useSSL ); ?>" class="form-validate" onSubmit="return myValidate(this);>
.
.
.
<textarea class="required" name="customer_comment" cols="50" rows="4" ><?php echo $this->cart->customer_comment?></textarea>

But nothing happen when I clicked on 'Check out' or 'Confirm Order' button.
Sorry, I am still beginner :'(. It would be really grateful if you give me some more advice for this. Thank you very much!

David
Title: Re: How to make the User comment text box as a Required field???
Post by: Milbo on July 05, 2012, 10:13:16 am
Maybe it is easier to create a shopperfield for that and ask for that in the address part.
Title: Re: How to make the User comment text box as a Required field???
Post by: david.kwock on July 06, 2012, 01:51:56 am
Milbo,

I solved it by calling another java script from the 'Check out' button in view.html.php in the Cart folder
and I call the 'Check out' java script in the other javascript in default.php:)

Cheers

David
Title: Re: How to make the User comment text box as a Required field???
Post by: disco_dancer on September 04, 2012, 21:20:49 pm
Hello David,
Can you please share how did you achieve this comment field validation?

Thanks
Title: Re: How to make the User comment text box as a Required field???
Post by: mpdeepan on September 27, 2012, 16:27:18 pm
Hello David

Can you please write how did you made this comment field validation?
Can you give code please?

Thanks
-Pradeepan-
Title: Re: How to make the User comment text box as a Required field???
Post by: david.kwock on October 04, 2012, 05:50:39 am
Hey, this is what I have done. This is a required field validation for my order timing validation (calendar).
You may use this method for your needs.  ;D

First file:\components\com_virtuemart\views\cart\view.html.php
This modification is to insert the Java form validation on the cart page instead of submitting the form straight away.
Code: [Select]
if (!VmConfig::get('use_as_catalog')) {
//$checkout_link_html = '<a class="vm-button-correct" href="javascript:document.checkoutForm.submit();" ><span>' . $text . '</span></a>'; -- original code
$checkout_link_html = '<a class="vm-button-correct" href="javascript:myValidate(this);" ><span>' . $text . '</span></a>';//replaced code
} else {
$checkout_link_html = '';
}
$this->assignRef('checkout_link_html', $checkout_link_html);
}


2nd file:\html\com_virtuemart\cart\default.php - this is a template override file

Insert this java script and replace the 'ordertiming' as you want. It would be 'comment' for you.
Code: [Select]
<script language="javascript">
function myValidate(f) {
    var ot = document.getElementById('ordertiming');

//document.checkoutForm.submit();
   if (ot.value=="") {
      alert('Please Select the Order Timing');
     
   }
   else {
      document.checkoutForm.submit();
   }
   
}

Hope this helps you guys. cheers
Title: Re: How to make the User comment text box as a Required field???
Post by: mpdeepan on October 04, 2012, 11:15:19 am
Thank you very much David.

God bless you.
-mpdeepan-
Title: Re: How to make the User comment text box as a Required field???
Post by: enserk on January 01, 2013, 19:54:42 pm
Hey, this is what I have done. This is a required field validation for my order timing validation (calendar).
You may use this method for your needs.  ;D

First file:\components\com_virtuemart\views\cart\view.html.php
This modification is to insert the Java form validation on the cart page instead of submitting the form straight away.
Code: [Select]
if (!VmConfig::get('use_as_catalog')) {
//$checkout_link_html = '<a class="vm-button-correct" href="javascript:document.checkoutForm.submit();" ><span>' . $text . '</span></a>'; -- original code
$checkout_link_html = '<a class="vm-button-correct" href="javascript:myValidate(this);" ><span>' . $text . '</span></a>';//replaced code
} else {
$checkout_link_html = '';
}
$this->assignRef('checkout_link_html', $checkout_link_html);
}


2nd file:\html\com_virtuemart\cart\default.php - this is a template override file

Insert this java script and replace the 'ordertiming' as you want. It would be 'comment' for you.
Code: [Select]
<script language="javascript">
function myValidate(f) {
    var ot = document.getElementById('ordertiming');

//document.checkoutForm.submit();
   if (ot.value=="") {
      alert('Please Select the Order Timing');
     
   }
   else {
      document.checkoutForm.submit();
   }
   
}

Hope this helps you guys. cheers
Hi David,

it doesnt work ... what can make worn?