Skip Navigation

[Resuelto] remove formating from input

This support ticket is created hace 6 años, 11 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Este tema contiene 18 respuestas, tiene 2 mensajes.

Última actualización por Akhil hace 6 años, 11 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#598727

hi. currently i have this issue.

if the user enter , "10,000" i dont get any result.
is there way to remove this formating ?

i ve seen sample here not sure if it fit the need

https://toolset.com/forums/topic/parametric-search-numeric-slider-for-price-range/page/2/

#598728

the location is filter views. using layouts.

#598737

is this ok ? i receive error "SyntaxError: missing ; before statement"

( function( $ ) {

	 $( document ).ready( function(){
	 //$("input[name='property-price_min']").attr('type', 'number');
	 //$("input[name='property-price_min']").attr('min', '1000');
	 //$("input[name='property-price_min']").attr('max', '100000000');
	   $("input[name='property-price_min']").mask('#,##0', {reverse: true});
	 });
 
    $('.wpv-filter-form').submit(function() {

	 //property-price_min convert to plain number after form submit
	 var property-price_min=$('#wpv_control_textfield_property-price_min').val();
	 property-price_min=property-price_min.replace(/,/g,'');
	 property-price_min=parseInt(property-price_min,10);
	 $('#wpv_control_textfield_property-price_min').val(property-price_min);

	 //property-price_max convert to plain number after form submit
	 var property-price_maxe=$('#wpv_control_textfield_property-price_max').val();
	 property-price_max=property-price_max.replace(/,/g,'');
	 property-price_max=parseInt(property-price_max,10);
	 $('#wpv_control_textfield_property-price_max').val(property-price_max);
	 
     return true;
     });
 
})( jQuery );

#598799

Dear C6410,

It is a custom JS codes problem, I assume you are using other custom JS: jQuery Mask Plugin:
enlace oculto

I just tested your JS codes in my localhost, you are using wrong var name in the JS codes, there should not be character "-" insider the var name, for example this code:

var property-price_min

Should be:

var property_price_min

So you will need to replace your JS codes as below:

( function( $ ) {
 
     $( document ).ready( function(){
       $("input[name='property-price_min']").mask('#,##0', {reverse: true});
       $("input[name='property-price_max']").mask('#,##0', {reverse: true});
     });
  
    $('.wpv-filter-form').submit(function() {
 
     //property-price_min convert to plain number after form submit
     var property_price_min=$("input[name='property-price_min']").val();
     property_price_min=property_price_min.replace(/,/g,'');
     property_price_min=parseInt(property_price_min,10);
     $('#wpv_control_textfield_property-price_min').val(property_price_min);
 
     //property-price_max convert to plain number after form submit
     var property_price_max=$("input[name='property-price_max']").val();
     property_price_max=property_price_max.replace(/,/g,'');
     property_price_max=parseInt(property_price_max,10);
     $("input[name='property-price_max']").val(property_price_max);
      
     return true;
     });
  
})( jQuery );
#598803

Hi Luo. thank you for looking into this.

can i give you backend to check the code pls.

the login that you have is valid i hope. pls let me know if it doesnt work.
its quite a mess there with many js code but nothing is new for you 🙂

thanks

#598810

OK, please provide the credentials and point out the URLs

#598821

I just checked it in your website, see this:
enlace oculto
click "Office Space Search ", and input number value into fields: "property-price_min" and "property-price_max"

Only number value can be inputted, and the Jquery Mask does not work in your website, see screenshot: property-price.JPG

so no formatting need to be removed, can you confirm it?

If there is anything missing, please provide the steps to see the problem, where should I check? thanks

#598827

Hi Luo. i added the code for the "/listings/landed-house/ " the rest remain untouch. thanks

pls look at the url i gave you to edit.

#598831

Same problem: Jquery Mask does not work in your website, I can not input into the fields("property-price_min" and "property-price_max"), more than three digital, if I input the 4th digital, I get the JS error:
The specified value "1,234" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+\.\d+|\.\d+)([eE][-+]?\d+)?

Please try it in your website:
enlace oculto

I suggest you fix the Jquery mask issue first, then follow again this thread.

#598902

Hi Luo.

its actually was working i think it conflct with this line after added /uncomment the line.

$("input[name='property-price_min']").attr('type', 'number');

for this mask script i think cannot have assign type-number i think,

#599118

OK, I have done below modification in your website:
1) comment the line. you mentioned above:
//$("input[name='property-price_min']").attr('type', 'number');

2) Change the JS codes as below:

$('.wpv-submit-trigger').on('click', function() {
     //property-price_min convert to plain number after form submit
     var property_price_min=$("input[name='property-price_min']").val();
     property_price_min=property_price_min.replace(/,/g,'');
     property_price_min=parseInt(property_price_min,10);
     $("input[name='property-price_min']").val(property_price_min);
  
     //property-price_max convert to plain number after form submit
     var property_price_max=$("input[name='property-price_max']").val();
     property_price_max=property_price_max.replace(/,/g,'');
     property_price_max=parseInt(property_price_max,10);
     $("input[name='property-price_max']").val(property_price_max);
       
     return true;
     });
 

Please test again, check if it is fixed.

#599120

Morning Luo. i am checking it now. it seems but some limitations.

1. when i presss the search with 'no any input value' it displays "Nan" .
2. it seem that it require 2 value in order to search , i cant search with ONLY or MAX only value.

i'm looking further now.

i m hoping that we can close this ticket today as weekend is coming. thanks.

#599123

It need to check if the field value is not empty, then remove the formatting, so the JS codes should be like this:

     //property-price_min convert to plain number after form submit
     var property_price_min=$("input[name='property-price_min']").val();
     if(property_price_min != ''){
     	property_price_min=property_price_min.replace(/,/g,'');
     	property_price_min=parseInt(property_price_min,10);
     	$("input[name='property-price_min']").val(property_price_min);
     }
  
     //property-price_max convert to plain number after form submit
     var property_price_max=$("input[name='property-price_max']").val();
     if(property_price_max != ''){
     	property_price_max=property_price_max.replace(/,/g,'');
     	property_price_max=parseInt(property_price_max,10);
     	$("input[name='property-price_max']").val(property_price_max);
     }
#599124

i think this is almost perfect, one last thing

1. is it possible the format to return back to mask value in the input box back for UI purpose. ?
2. how do i enforce the type=number only esp in the mobile where the keypad only display digits. this is important as not to frustrate the mobile users.
3. i will need to copy the code to rest of the field that involve numbers , ill do that soon.

many thanks!

#599125

Q1) is it possible the format to return back to mask value in the input box back for UI purpose. ?
It is a new question, since you are using AJAX search, you will need to trigger the "mask" JS effect after the AJAX search is competed, for example:

$(document).on('js_event_wpv_parametric_search_results_updated', function(){
...
});

If you still need assistance for it, please create new thread for it.

Q2) How do i enforce the type=number only esp in the mobile where the keypad only display digits. this is important as not to frustrate the mobile users.
There isn't such a built-in feature within Views plugin,
And according to our support policy, we don't provide custom code support, I suggest you check it with the Toolset Contractors:
https://toolset.com/contractors/
And same as above, It is a new question, If you still need assistance for it, please create new thread for it.

Please create different threads for each question, that will help other users to find the answers.