I have a form that when submitted to the server will contain mas in the query string values, for example:
test/?manufacturer=0&body-style=0&min-price=270%2C000&max-price=780%2C000
Is there a way to remove this ma using JS just after the user clicks the form but before it will be submitted to the server? I have this approach here: How replace query string values using jQuery?
But that will only change the text to integer but in the URL itself. I also tried using input number attribute in HTML 5 but I cannot figure out how to use a ma by default to show it on the form: How to force to display a number with a ma with input type number?
I would appreciate any tips. Thanks.
UPDATE
Final working solution:
$('.my_form').submit(function() {
var x=$('#input_text_field_one').val();
x=x.replace(/,/g,'');
x=parseInt(x,10);
$('#input_text_field_one').val(x);
return true;
});
input_text_field_one is the input text form containing a number with mas. .my_form is the class name for the form. After form submit the above code replace the numbers with mas to without mas. So finally, the numbers are submitted as number. :)
I have a form that when submitted to the server will contain mas in the query string values, for example:
test./?manufacturer=0&body-style=0&min-price=270%2C000&max-price=780%2C000
Is there a way to remove this ma using JS just after the user clicks the form but before it will be submitted to the server? I have this approach here: How replace query string values using jQuery?
But that will only change the text to integer but in the URL itself. I also tried using input number attribute in HTML 5 but I cannot figure out how to use a ma by default to show it on the form: How to force to display a number with a ma with input type number?
I would appreciate any tips. Thanks.
UPDATE
Final working solution:
$('.my_form').submit(function() {
var x=$('#input_text_field_one').val();
x=x.replace(/,/g,'');
x=parseInt(x,10);
$('#input_text_field_one').val(x);
return true;
});
input_text_field_one is the input text form containing a number with mas. .my_form is the class name for the form. After form submit the above code replace the numbers with mas to without mas. So finally, the numbers are submitted as number. :)
Share Improve this question edited May 23, 2017 at 12:12 CommunityBot 11 silver badge asked Jun 27, 2013 at 11:51 Emerson ManingoEmerson Maningo 2,2799 gold badges33 silver badges48 bronze badges 3- what's the problem exactly ? why can't you just take care of the eventual mas server-side ? What if at some point the value after the ma is not 0 ? – Laurent S. Commented Jun 27, 2013 at 11:55
- Yes this is easy server side but it's a plugin that is beyond my control. I don't want to edit the plugin core source code because I'm not allowed. And there are no hooks to override. – Emerson Maningo Commented Jun 27, 2013 at 12:05
- Final solution that works I posted it on my question.. – Emerson Maningo Commented Jun 27, 2013 at 12:39
1 Answer
Reset to default 5I think you want something like this:-
form.onSubmit = function(){
form.action = form.action.replace(",", "");
return true;
}