Hi,
I have this form:
http://www.sgagrafica.com/index.php?page=shop.product_details&flypage=flypage_new.tpl&product_id=100&category_id=7&option=com_virtuemart&Itemid=126
On the first select I have 2 option (color RED) that are an OFFER.
I have done a LIVEVALIDATION for these option that the user can make an order only if the field SUPERFICIE (calculated by BASE*ALTEZZA) is more than 10.
Here my validation:
This is the problem:
if i select a option that is not 10 or 20 (value)...I can make an order...ALL OK
if i select a option OFFERTA (10 or 20) and SUPERFICIE is minor than 10...Form il locked...ALL OK
if i select a option OFFERTA (10 or 20) and SUPERFICIE is maior than 10...I can make an order...ALL OK
NOW:
If I don't go forward to do an order and i would change the value of SELECT menu selecting another option (not OFFERTA so not 10 or 20 option value of select)...I should be able to make and order...but nothing...the form remains locked as if I have selected an option OFFERTA (10 or 20).
Where is the error in live validation code?
I have this form:
http://www.sgagrafica.com/index.php?page=shop.product_details&flypage=flypage_new.tpl&product_id=100&category_id=7&option=com_virtuemart&Itemid=126
On the first select I have 2 option (color RED) that are an OFFER.
I have done a LIVEVALIDATION for these option that the user can make an order only if the field SUPERFICIE (calculated by BASE*ALTEZZA) is more than 10.
Here my validation:
if ( (tipo=="10") || (tipo=="20") ) {
//alert("sei dentro");
window.addEvent('domready', function(){
var valid = new LiveValidation('text_4');
valid.add(Validate.Numericality, { minimum: 10, failureMessage: "NOOOOOOOOOO" });
});
}
This is the problem:
if i select a option that is not 10 or 20 (value)...I can make an order...ALL OK
if i select a option OFFERTA (10 or 20) and SUPERFICIE is minor than 10...Form il locked...ALL OK
if i select a option OFFERTA (10 or 20) and SUPERFICIE is maior than 10...I can make an order...ALL OK
NOW:
If I don't go forward to do an order and i would change the value of SELECT menu selecting another option (not OFFERTA so not 10 or 20 option value of select)...I should be able to make and order...but nothing...the form remains locked as if I have selected an option OFFERTA (10 or 20).
Where is the error in live validation code?
I'm testing and seems that once I have selected an option OFFERTA (value 10 or 20) the code (live validation) under IF steatement remains active eaven if I change the option value in that select.
Why?
Bob, can help me?
Regards and thanks so much for your wonderful works!!!
monak83
Why?
Bob, can help me?
Regards and thanks so much for your wonderful works!!!
monak83
Hi monak83,
As far as I can see you are adding the validation if those options are selected - but you aren't removing them again if the validations are un-selected.
I never worked out how to remove a validation in LiveValidation (which is why I wrote the Hidden Inputs tutorial using the QuirksMode validation library and not LiveValidation). BUT 'polderguy' did post here recently that they and got the LiveValidation disable() and enable() functions to work after reading this post on StackOverflow. I haven't had time to follow up but this may help you.
Bob
As far as I can see you are adding the validation if those options are selected - but you aren't removing them again if the validations are un-selected.
I never worked out how to remove a validation in LiveValidation (which is why I wrote the Hidden Inputs tutorial using the QuirksMode validation library and not LiveValidation). BUT 'polderguy' did post here recently that they and got the LiveValidation disable() and enable() functions to work after reading this post on StackOverflow. I haven't had time to follow up but this may help you.
Bob
Hi Bob,
I have read your link and I tried to this code:
the validation message works correctly: if I select value 10 or 20 the field SUPERFICIE must be maior than 10 and I see the error message, otherwise the error message doesen't appears eaven if the field SUPERFICIE is minor than 10.
The problem is that the forms remains loocked...why? Any Ideas?
I have read your link and I tried to this code:
if ( (tipo=="10") || (tipo=="20") ) {
//alert("sei dentro");
window.addEvent('domready', function(){
var valid = new LiveValidation('text_4', {insertAfterWhatNode : "errore"});
valid.add(Validate.Numericality, { minimum: 10, tooLowMessage: "Minimo 10 mq per i prodotti in OFFERTA" });
});
} else {
window.addEvent('domready', function(){
var valid = new LiveValidation('text_4', {insertAfterWhatNode : "errore"});
valid.remove(Validate.Numericality, { minimum: 10, tooLowMessage: "Minimo 10 mq per i prodotti in OFFERTA" });
});
}
the validation message works correctly: if I select value 10 or 20 the field SUPERFICIE must be maior than 10 and I see the error message, otherwise the error message doesen't appears eaven if the field SUPERFICIE is minor than 10.
The problem is that the forms remains loocked...why? Any Ideas?
Hi monak83,
If I have time this afternoon I'll take a look. I've spent hours on this in the past and am not too keen to get into the code again :-(
From tomorrow I'm away until 27 Dec - I will look when I am back if not before.
Bob
If I have time this afternoon I'll take a look. I've spent hours on this in the past and am not too keen to get into the code again :-(
From tomorrow I'm away until 27 Dec - I will look when I am back if not before.
Bob
Hi monak83,
I've made some progress with this on a copy of your form . . . and then get stuck because the updatethis() function doesn't always run. I think that you have different code trying to use the same events :-(
Basically I think that you need to declare the params object for the validation and set up the validation once at the domready event
Then in the checking function turn the validation on and off with
Bob
I've made some progress with this on a copy of your form . . . and then get stuck because the updatethis() function doesn't always run. I think that you have different code trying to use the same events :-(
Basically I think that you need to declare the params object for the validation and set up the validation once at the domready event
window.addEvent('domready', function() {
var params = {
minimum: 10,
tooLowMessage: "Minimo 10 mq per i prodotti in OFFERTA"
};
var valid = new LiveValidation('text_4', {
insertAfterWhatNode : "errore"
});
. . .
Then in the checking function turn the validation on and off with
if ( (tipo == "10") || (tipo == "20") ) {
valid.add(Validate.Numericality, params);
} else {
valid.remove(Validate.Numericality, params);
};
Bob
Hi Bob,
I have tried but with you code now the forms dosen't works: the total amount is not calculated and this validation not works.
You can see the form with you code here:
http://www.sgagrafica.com/index.php?page=shop.product_details&flypage=flypage_new.tpl&product_id=100&category_id=7&option=com_virtuemart&Itemid=126&vmcchk=1&Itemid=118
You code is between //BOB CODE comments.
Thanks for your help...
monak83
I have tried but with you code now the forms dosen't works: the total amount is not calculated and this validation not works.
You can see the form with you code here:
http://www.sgagrafica.com/index.php?page=shop.product_details&flypage=flypage_new.tpl&product_id=100&category_id=7&option=com_virtuemart&Itemid=126&vmcchk=1&Itemid=118
You code is between //BOB CODE comments.
Thanks for your help...
monak83
Hi monak83,
Please try removing the window.addEvent lines from the first block. There is an error showing because valid isn't defined.
Bob
Please try removing the window.addEvent lines from the first block. There is an error showing because valid isn't defined.
var params = {
minimum: 10,
tooLowMessage: "Minimo 10 mq per i prodotti in OFFERTA"
};
var valid = new LiveValidation('text_4', {
insertAfterWhatNode : "errore"
});
Bob
dosen't works...the total amount is blank...and the validation for product OFFERTA not works!
Hi monak83,
Looks now as if 'text_4' isn't defined when that runs. You'll need to put back the window.addEvent lines and make sure that the 'updatethis' function only runs after 'valid' is defined.
Bob
Looks now as if 'text_4' isn't defined when that runs. You'll need to put back the window.addEvent lines and make sure that the 'updatethis' function only runs after 'valid' is defined.
Bob
This topic is locked and no more replies can be posted.