Hi,
I have a form where users puts dimensions of a banner.
Dimensions are width and heigth.
These dimensions can be also decimal like "12.4".
My users are italian and they use COMMA and non DOT so if they put "12,4" javascript validation number system makes an error.
So I whould replace COMMA with DOT automatically.
Here a piece of my form:
I have found online this solution:
and I have modified my code like here:
but doesn't update every time my input box, some times yes and sometimes no.
Why?
You can see my form here:
http://www.sgagrafica.com/index.php?option=com_content&view=article&id=77&Itemid=120
Regards
monak83
I have a form where users puts dimensions of a banner.
Dimensions are width and heigth.
These dimensions can be also decimal like "12.4".
My users are italian and they use COMMA and non DOT so if they put "12,4" javascript validation number system makes an error.
So I whould replace COMMA with DOT automatically.
Here a piece of my form:
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 440px;">Base (in cm)</label>
<input class="cf_inputbox required validate-number" maxlength="150" size="5" id="text_2" name="base" type="text" onChange="updatethis(this.form);" value="" />
I have found online this solution:
onchange="this.value=this.value.replace(/\,/,'.');"
and I have modified my code like here:
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 440px;">Base (in cm)</label>
<input class="cf_inputbox required validate-number" maxlength="150" size="5" id="text_2" name="base" type="text" onChange="updatethis(this.form); this.value=this.value.replace(/\,/,'.');" value="" />
but doesn't update every time my input box, some times yes and sometimes no.
Why?
You can see my form here:
http://www.sgagrafica.com/index.php?option=com_content&view=article&id=77&Itemid=120
Regards
monak83
Hi monak83,
Here's a script that seems to work OK. Add it to the Form JavaScript box, then add the 'no_comma' class to any inputs where you want to have the comma replaced.
Here's your input with the class added:
Bob
Here's a script that seems to work OK. Add it to the Form JavaScript box, then add the 'no_comma' class to any inputs where you want to have the comma replaced.
window.addEvent('domready', function() {
$$('.no_comma').each(function(item) {
item.addEvent('keyup', function(){
this.value = this.value.replace(/,/, '.') ;
});
});
});
Here's your input with the class added:
<input class="cf_inputbox required validate-number no_comma" maxlength="150" size="5" id="text_2" name="base" type="text" value="" />
Bob
Hi Bob,
I have tried and under Firefox no problem but under Internet Explorer there are some problems: sometimes the others fields don't upgrade automatically also if the comma is replaced always correctly into a dot.
If I delete your function all works correctly so I think there is a conflict in your function.
Can you help me?
Here my form:
http://www.sgagrafica.com/index.php?option=com_content&view=article&id=76&Itemid=119
I have tried and under Firefox no problem but under Internet Explorer there are some problems: sometimes the others fields don't upgrade automatically also if the comma is replaced always correctly into a dot.
If I delete your function all works correctly so I think there is a conflict in your function.
Can you help me?
Here my form:
http://www.sgagrafica.com/index.php?option=com_content&view=article&id=76&Itemid=119
Hi monak83,
I took a look at the form but as the superficie input appears to be both required and readonly I gave up.
I did see that in IE9 there is this error "Line: 522
Error: The value of the property 'BixFormUpdate' is null or undefined, not a Function object"
Bob
I took a look at the form but as the superficie input appears to be both required and readonly I gave up.
I did see that in IE9 there is this error "Line: 522
Error: The value of the property 'BixFormUpdate' is null or undefined, not a Function object"
Bob
So is not a problem caused by "replace comma into dot" function?
How should I do?
Thanks so much for your time Bob.
monak83
How should I do?
Thanks so much for your time Bob.
monak83
Hi monak83,
It may be a problem with my code snippet - though in the tests I ran that seemed to be OK. If everything else works whe you remove it then it could be a problem.
But the readonly+required input makes the form practically unusable anyhow.
Bob
It may be a problem with my code snippet - though in the tests I ran that seemed to be OK. If everything else works whe you remove it then it could be a problem.
But the readonly+required input makes the form practically unusable anyhow.
Bob
Hi Bob thnaks so much for your patience but I think it's a a problem caused not by readonly+required field option because if you try in other form like this:
http://www.sgagrafica.com/index.php?option=com_content&view=article&id=75&Itemid=118
the problem is present also if there isn't the field readonly+required.
Now? What we can do?
Thakns so much
Regards
monak83
http://www.sgagrafica.com/index.php?option=com_content&view=article&id=75&Itemid=118
the problem is present also if there isn't the field readonly+required.
Now? What we can do?
Thakns so much
Regards
monak83
Hi monak83,
I don't think that is causing the problem but it makes the form unusable so I'm not going to waste time on it.
And on the other form you linked to there is a JavaScript error that 'displaydesc is not defined'. That seems to be some other script that is missing or broken.
Bob
I don't think that is causing the problem but it makes the form unusable so I'm not going to waste time on it.
And on the other form you linked to there is a JavaScript error that 'displaydesc is not defined'. That seems to be some other script that is missing or broken.
Bob
This topic is locked and no more replies can be posted.