Author Topic: How to make the User comment text box as a Required field???  (Read 5377 times)

david.kwock

  • Beginner
  • *
  • Posts: 17
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

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9905
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: How to make the User comment text box as a Required field???
« Reply #1 on: July 04, 2012, 12:39:01 pm »
FE/views/cart/tmpl/default.php
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

david.kwock

  • Beginner
  • *
  • Posts: 17
Re: How to make the User comment text box as a Required field???
« Reply #2 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

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9905
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: How to make the User comment text box as a Required field???
« Reply #3 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.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

david.kwock

  • Beginner
  • *
  • Posts: 17
Re: How to make the User comment text box as a Required field???
« Reply #4 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

disco_dancer

  • Beginner
  • *
  • Posts: 23
Re: How to make the User comment text box as a Required field???
« Reply #5 on: September 04, 2012, 21:20:49 pm »
Hello David,
Can you please share how did you achieve this comment field validation?

Thanks

mpdeepan

  • Beginner
  • *
  • Posts: 17
Re: How to make the User comment text box as a Required field???
« Reply #6 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-

david.kwock

  • Beginner
  • *
  • Posts: 17
Re: How to make the User comment text box as a Required field???
« Reply #7 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

mpdeepan

  • Beginner
  • *
  • Posts: 17
Re: How to make the User comment text box as a Required field???
« Reply #8 on: October 04, 2012, 11:15:19 am »
Thank you very much David.

God bless you.
-mpdeepan-

enserk

  • Beginner
  • *
  • Posts: 7
Re: How to make the User comment text box as a Required field???
« Reply #9 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?