VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: concap on February 14, 2013, 04:36:07 AM

Title: State / Province / Region * required field is not working
Post by: concap on February 14, 2013, 04:36:07 AM
G'day,
when filling up billing address information, condition for required field 'State / Province / Region' is skipped. Which means that when customer leaves 'State / Province / Region' on default value = -Select- then Customer is not notified about required field and form gets saved.

I've checked that Configuration->shoper fields virtuemart_state_id Required is checked.
Joomla2.5.9 VM2.0.18a

Anybody knows what is wrong?
Title: Re: State / Province / Region * required field is not working
Post by: jetdeck on February 17, 2013, 01:40:44 AM
Having same problem....anybody??
Title: Re: State / Province / Region * required field is not working
Post by: dhefley on February 21, 2013, 15:47:48 PM
Same here; I thought it was an IE thing, but it isn't...just started happening with upgrade to 2.0.18a
Title: Re: State / Province / Region * required field is not working
Post by: PRO on February 21, 2013, 16:03:49 PM
template override?

I know it works on mine
Title: Re: State / Province / Region * required field is not working
Post by: dhefley on February 21, 2013, 16:31:40 PM
It seems to me it works on mine, partly, as well (with our without template overrides, but that was a good suggestion!).  *If* I put in my address, and select a Country with State/Prov/Region as my first selection, it requires me to pick a state.  However, if I pick a country without one (like by typing in the select, just selecting) and then pick a country with a state, it then does not validate.

Here is how I reproduce:
Using CHROME:
Go to <site>/products/user/editaddresscartBT

Step 1:
Fill all fields with "Test"
Select Angola from Country
Select United States from Country
Click on Checkout as Guest
It saves and returns to cart screen

Step 2:
If I now click on Add/Edit Billing Address
It shows United States as country, -- Select -- from State
If I click on "Checkout as Guest", it tool tips the "Please Select an Item in the List" for state, but then the form submits anyway and returns to cart screen

Step 3:
If I now click on Add/Edit Billing Address
Change Country to -- Select --, it won't let me submit with an alert of  "Required Field Missing"
Pick United States, and the tool tip "Please Select an Item in the List" for state comes up again, but, once again, the form submits anyway.


If I try this in Firefox:
Step 1 behaves the same.
Step 2 and 3: I get the tool tip on the State select, but the form DOES NOT submit now...

If I try this in IE9:
Step 1: Even if I select United States first, it immediately allows form submission.
Step 2 and 3: No tooltip, just submits form, regardless of status of Country or State...
Title: Re: State / Province / Region * required field is not working
Post by: concap on March 04, 2013, 04:37:19 AM
Has anybody come up with solution?
Title: Re: State / Province / Region * required field is not working
Post by: PRO on March 04, 2013, 21:06:52 PM
Quote from: dhefley on February 21, 2013, 16:31:40 PM
It seems to me it works on mine, partly, as well (with our without template overrides, but that was a good suggestion!).  *If* I put in my address, and select a Country with State/Prov/Region as my first selection, it requires me to pick a state.  However, if I pick a country without one (like by typing in the select, just selecting) and then pick a country with a state, it then does not validate.

Here is how I reproduce:
Using CHROME:
Go to <site>/products/user/editaddresscartBT

Step 1:
Fill all fields with "Test"
Select Angola from Country
Select United States from Country
Click on Checkout as Guest
It saves and returns to cart screen

Step 2:
If I now click on Add/Edit Billing Address
It shows United States as country, -- Select -- from State
If I click on "Checkout as Guest", it tool tips the "Please Select an Item in the List" for state, but then the form submits anyway and returns to cart screen

Step 3:
If I now click on Add/Edit Billing Address
Change Country to -- Select --, it won't let me submit with an alert of  "Required Field Missing"
Pick United States, and the tool tip "Please Select an Item in the List" for state comes up again, but, once again, the form submits anyway.


If I try this in Firefox:
Step 1 behaves the same.
Step 2 and 3: I get the tool tip on the State select, but the form DOES NOT submit now...

If I try this in IE9:
Step 1: Even if I select United States first, it immediately allows form submission.
Step 2 and 3: No tooltip, just submits form, regardless of status of Country or State...


do you use more than 1 country?

I know the newest vmart you can choose a "default" USA and the states will be filled.

Title: Re: State / Province / Region * required field is not working
Post by: concap on March 05, 2013, 04:32:38 AM
Default country is set to Australia if it makes any difference.
Title: Re: State / Province / Region * required field is not working
Post by: PRO on March 05, 2013, 11:01:17 AM
are you using a template override?
Title: Re: State / Province / Region * required field is not working
Post by: concap on March 05, 2013, 11:17:26 AM
What would be the template which overwrites particular file?
Title: Re: State / Province / Region * required field is not working
Post by: PRO on March 05, 2013, 11:21:12 AM
post your url
Title: Re: State / Province / Region * required field is not working
Post by: Akarr on April 06, 2013, 13:48:40 PM
Quote from: concap on February 14, 2013, 04:36:07 AM
G'day,
when filling up billing address information, condition for required field 'State / Province / Region' is skipped. Which means that when customer leaves 'State / Province / Region' on default value = -Select- then Customer is not notified about required field and form gets saved.

I've checked that Configuration->shoper fields virtuemart_state_id Required is checked.
Joomla2.5.9 VM2.0.18a

Anybody knows what is wrong?

in shopper field list disable the virtuemart_state_id and that should do the trick. if your shop is outside US and dont need the US states
Title: Re: State / Province / Region * required field is not working
Post by: forprobe on June 12, 2013, 22:27:59 PM
and if I have only US with its states? what is the solution?
Title: Re: State / Province / Region * required field is not working
Post by: PRO on June 14, 2013, 10:53:46 AM
Quote from: forprobe on June 12, 2013, 22:27:59 PM
and if I have only US with its states? what is the solution?

what is your exact problem?

& are you using the newest version?
Title: Re: State / Province / Region * required field is not working
Post by: ChrisTDR on August 21, 2013, 12:17:43 PM
Here's a solution that may solve some people's problems. I am using a template, that does not have any over-riding files for User.

I found that in components/com_virtuemart/views/user/tmpl/edit_address.php - there is a section that reads:

function callValidatorForRegister(f){

        var elem = jQuery('#username_field');
        elem.attr('class', "required");

        var elem = jQuery('#name_field');
        elem.attr('class', "required");

        var elem = jQuery('#password_field');
        elem.attr('class', "required");

        var elem = jQuery('#password2_field');
        elem.attr('class', "required");

        var elem = jQuery('#userForm');


The last line containing: #userForm appears to attempt to validate the whole userform (the fields below Username and Password)

I changed this to name each field individually like this:

function callValidatorForRegister(f){

        var elem = jQuery('#username_field');
        elem.attr('class', "required");

        var elem = jQuery('#name_field');
        elem.attr('class', "required");

        var elem = jQuery('#password_field');
        elem.attr('class', "required");

        var elem = jQuery('#password2_field');
        elem.attr('class', "required");

        var elem = jQuery('#first_name');
elem.attr('class', "required");

var elem = jQuery('#last_name');
elem.attr('class', "required");

var elem = jQuery('#address_1');
elem.attr('class', "required");

var elem = jQuery('#zip');
elem.attr('class', "required");

var elem = jQuery('#city');
elem.attr('class', "required");

var elem = jQuery('#virtuemart_country_id');
elem.attr('class', "required");

var elem = jQuery('#virtuemart_state_id');
elem.attr('class', "required");


(you may be using more fields that this - the field names can be found in the 'Shopper Fields' configuration area of the backend) - just start each with '#'

This works for me, I know this because when I click 'Register' on an empty form, all the required fields that have validation appear with a yellow highlight and this now includes the State field.

Hope this helps people.
Title: Re: State / Province / Region * required field is not working
Post by: romatvirtue on January 26, 2014, 00:01:37 AM
Quote from: ChrisTDR on August 21, 2013, 12:17:43 PM
Here's a solution that may solve some people's problems. I am using a template, that does not have any over-riding files for User.

I found that in components/com_virtuemart/views/user/tmpl/edit_address.php - there is a section that reads:

function callValidatorForRegister(f){

        var elem = jQuery('#username_field');
        elem.attr('class', "required");

        var elem = jQuery('#name_field');
        elem.attr('class', "required");

        var elem = jQuery('#password_field');
        elem.attr('class', "required");

        var elem = jQuery('#password2_field');
        elem.attr('class', "required");

        var elem = jQuery('#userForm');


The last line containing: #userForm appears to attempt to validate the whole userform (the fields below Username and Password)

I changed this to name each field individually like this:

function callValidatorForRegister(f){

        var elem = jQuery('#username_field');
        elem.attr('class', "required");

        var elem = jQuery('#name_field');
        elem.attr('class', "required");

        var elem = jQuery('#password_field');
        elem.attr('class', "required");

        var elem = jQuery('#password2_field');
        elem.attr('class', "required");

        var elem = jQuery('#first_name');
elem.attr('class', "required");

var elem = jQuery('#last_name');
elem.attr('class', "required");

var elem = jQuery('#address_1');
elem.attr('class', "required");

var elem = jQuery('#zip');
elem.attr('class', "required");

var elem = jQuery('#city');
elem.attr('class', "required");

var elem = jQuery('#virtuemart_country_id');
elem.attr('class', "required");

var elem = jQuery('#virtuemart_state_id');
elem.attr('class', "required");


(you may be using more fields that this - the field names can be found in the 'Shopper Fields' configuration area of the backend) - just start each with '#'

This works for me, I know this because when I click 'Register' on an empty form, all the required fields that have validation appear with a yellow highlight and this now includes the State field.

Hope this helps people.

Hello! I tried your solution, but this did not work for me... :(
Title: Re: State / Province / Region * required field is not working
Post by: romatvirtue on January 26, 2014, 08:16:42 AM
Quote from: ChrisTDR on August 21, 2013, 12:17:43 PM
Here's a solution that may solve some people's problems. I am using a template, that does not have any over-riding files for User.

I found that in components/com_virtuemart/views/user/tmpl/edit_address.php - there is a section that reads:

function callValidatorForRegister(f){

        var elem = jQuery('#username_field');
        elem.attr('class', "required");

        var elem = jQuery('#name_field');
        elem.attr('class', "required");

        var elem = jQuery('#password_field');
        elem.attr('class', "required");

        var elem = jQuery('#password2_field');
        elem.attr('class', "required");

        var elem = jQuery('#userForm');


The last line containing: #userForm appears to attempt to validate the whole userform (the fields below Username and Password)

I changed this to name each field individually like this:

function callValidatorForRegister(f){

        var elem = jQuery('#username_field');
        elem.attr('class', "required");

        var elem = jQuery('#name_field');
        elem.attr('class', "required");

        var elem = jQuery('#password_field');
        elem.attr('class', "required");

        var elem = jQuery('#password2_field');
        elem.attr('class', "required");

        var elem = jQuery('#first_name');
elem.attr('class', "required");

var elem = jQuery('#last_name');
elem.attr('class', "required");

var elem = jQuery('#address_1');
elem.attr('class', "required");

var elem = jQuery('#zip');
elem.attr('class', "required");

var elem = jQuery('#city');
elem.attr('class', "required");

var elem = jQuery('#virtuemart_country_id');
elem.attr('class', "required");

var elem = jQuery('#virtuemart_state_id');
elem.attr('class', "required");


(you may be using more fields that this - the field names can be found in the 'Shopper Fields' configuration area of the backend) - just start each with '#'

This works for me, I know this because when I click 'Register' on an empty form, all the required fields that have validation appear with a yellow highlight and this now includes the State field.

Hope this helps people.

My bad. I deleted var elem = jQuery('#userForm');

Now everything works great. What I noticed is that, this solution only works for "Register and Checkout" and not for "Checkout as Guest." I just called the "callValidatorForRegister" function for "Checkout as Guest" button as well. Thanks for your solution.
Title: Re: State / Province / Region * required field is not working
Post by: craftyweb on April 01, 2014, 18:01:11 PM
The problem here seems to be that the state select box is not getting the class of 'required'.

The bug lies in 'Administrator > com_virtuemart > helpers > shopfunctions.php'

Line 354 (in VirtueMart 2.0.26d) sets the required attribute but not the required class:


if ($required != 0) {
$attrs .= ' required';
}
$attrs .= ' class="vm-chzn-select"';


To make the state select box required change this to:


if ($required != 0) {
$attrs .= ' required class="vm-chzn-select required"';
} else {
$attrs .= ' class="vm-chzn-select"';
}
Title: Re: State / Province / Region * required field is not working
Post by: Milbo on April 02, 2014, 15:13:55 PM
almost right, but

if a country has no state, the whole thing must be unrequired. Best is just to test the new vm2.5.5, it should work directly there.
Title: Re: State / Province / Region * required field is not working
Post by: craftyweb on April 11, 2014, 13:04:23 PM
Thanks Milbo,

I don't have any active countries which don't have states. so that wouldn't be a problem on my sites.

Title: Re: State / Province / Region * required field is not working
Post by: michelabraham on October 08, 2014, 16:55:35 PM
Quote from: Akarr on April 06, 2013, 13:48:40 PM
Quote from: concap on February 14, 2013, 04:36:07 AM
G'day,
when filling up billing address information, condition for required field 'State / Province / Region' is skipped. Which means that when customer leaves 'State / Province / Region' on default value = -Select- then Customer is not notified about required field and form gets saved.

I've checked that Configuration->shoper fields virtuemart_state_id Required is checked.
Joomla2.5.9 VM2.0.18a

Anybody knows what is wrong?

in shopper field list disable the virtuemart_state_id and that should do the trick. if your shop is outside US and dont need the US states

Hello,
Thank you for this topic who can really help me. I want to remove the state fields because I live in France but I don't know where to delete this.
Akarr or anyone else, can you give me the road to in my ftp. I looked for days now.
Thank you very much
Michel
Title: Re: State / Province / Region * required field is not working
Post by: GJC Web Design on October 09, 2014, 11:11:41 AM
Just unpublish in your VM shopper fields admin