Hi,
I have a form where a select has some options: only for one options I would validate a field.
on my html file I have:
SELECT -> name="tipo_nolavorazioni"
OPTION -> 80 (from select name="tipo_nolavorazioni")
FIELD -> name="base"
on js file I have assigna variable like here:
- if TIPO1 = 80 I would validate field BASE < 250;
- if TIPO1 != 80 I would any validation
My problem is that the first time i load page all works good and when I select TIPO1 = 80 live validation works fine.
But when I change TIPO1 to a value different from 80 (TIPO1 != 80) live validation remains and I can't process my form.
I have add a remove function but dosent' works.
Here my code:
here my forms (now I have comment code that validate my forms because I'm on a live site)
http://www.sgagrafica.com/stampa-banner-striscioni.html
I have a form where a select has some options: only for one options I would validate a field.
on my html file I have:
SELECT -> name="tipo_nolavorazioni"
OPTION -> 80 (from select name="tipo_nolavorazioni")
FIELD -> name="base"
on js file I have assigna variable like here:
var tipo1 = form.elements['tipo_nolavorazioni'].value;
- if TIPO1 = 80 I would validate field BASE < 250;
- if TIPO1 != 80 I would any validation
My problem is that the first time i load page all works good and when I select TIPO1 = 80 live validation works fine.
But when I change TIPO1 to a value different from 80 (TIPO1 != 80) live validation remains and I can't process my form.
I have add a remove function but dosent' works.
Here my code:
window.addEvent('domready', function(){
var valid = new LiveValidation('text_2', {insertAfterWhatNode : "errore_base"});
if (tipo1==80) { valid.add(Validate.Numericality, { maximum: 250, tooHighMessage: "Max 250cm" }); };
if (tipo1!=80) { valid.remove(Validate.Numericality, { maximum: 250, tooHighMessage: "Max 250cm" }); valid.destroy(); };
});
here my forms (now I have comment code that validate my forms because I'm on a live site)
http://www.sgagrafica.com/stampa-banner-striscioni.html
Hello monak83,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How can I disable options in a select drop-down?
P.S: I'm just an automated service😉
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How can I disable options in a select drop-down?
P.S: I'm just an automated service😉
Hi monak83,
it looks as though your JavaScript only runs when the page is loaded. You presumably need it to run when the option selected changes?
Bob
it looks as though your JavaScript only runs when the page is loaded. You presumably need it to run when the option selected changes?
Bob
Hi Bob,
I have seen but seems that my live validation is under function onchange and so it should be called every time i change a value in my select.
Where I'm wrong?
I have seen but seems that my live validation is under function onchange and so it should be called every time i change a value in my select.
Where I'm wrong?
Hi Monak,
As Bob already suggested, you need to set your code to run when the select changes, just wrap the 3 lines inside into a select element change event.
Regards,
Max
As Bob already suggested, you need to set your code to run when the select changes, just wrap the 3 lines inside into a select element change event.
$('select').addEvent('change',function(event) {
//??
});
Regards,
Max
Hi Max,
I have added this cod at the bottom of my .js file...but dosen't works.
I have added out of my function updatethis(form) called with onchange.
Where i'm wrong?
http://www.sgagrafica.com/stampa-banner-striscioni.html
I have added this cod at the bottom of my .js file...but dosen't works.
I have added out of my function updatethis(form) called with onchange.
Where i'm wrong?
http://www.sgagrafica.com/stampa-banner-striscioni.html
window.addEvent('domready', function(){
$('select_5').addEvent('change',function(event) {
var valid = new LiveValidation('text_2', {insertAfterWhatNode : "errore_base"});
if (tipo1==80) { valid.add(Validate.Numericality, { maximum: 250, tooHighMessage: "Max 250cm" }); };
if (tipo1!=80) { valid.remove(Validate.Numericality, { maximum: 250, tooHighMessage: "Max 250cm" }); valid.destroy(); };
});
});
I monak83,
It's a few years since ChronoForms used LiveValidation and I'm not longer very familiar with it. The script you posted doesn't seem to have any onChange event?
Bob
It's a few years since ChronoForms used LiveValidation and I'm not longer very familiar with it. The script you posted doesn't seem to have any onChange event?
Bob
Hi Bob,
on my webpage you can see this:
http://www.sgagrafica.com/stampa-banner-striscioni.html
on my webpage you can see this:
<select class="cf_inputbox" id="select_5" size="1" title="Effettua una scelta!" name="tipo_nolavorazioni"
onkeyup="validateNumber()" onclick="validateNumber()" onChange="updatethis(this.form);">
http://www.sgagrafica.com/stampa-banner-striscioni.html
The onChange event calls a function named "updatethis", but the code you had should be triggered when any change is done to the field, assuming the page doesn't have any JS errors.
Where do you have your JS code placed ?
Where do you have your JS code placed ?
You can see on the HEAD tag of my page http://www.sgagrafica.com/stampa-banner-striscioni.html.
IF you would see a more clear view you can found js file called in head tag here: http://www.sgagrafica.com/forms/banner_peso.js
IF you would see a more clear view you can found js file called in head tag here: http://www.sgagrafica.com/forms/banner_peso.js
Hi Monak,
I'm not sure, please try again the code I posted, maybe with a new form field, just make sure the field id matches the one in the code, and check if it works, it may need some debugging before you can get it to work!
Regards,
Max
I'm not sure, please try again the code I posted, maybe with a new form field, just make sure the field id matches the one in the code, and check if it works, it may need some debugging before you can get it to work!
Regards,
Max
This topic is locked and no more replies can be posted.