Best practice to handle the special chars across the application

0
Hi All, We have multiple text fields on different screens where we would like to stop user from entering or copy pasting few set of chars like long dash (—). What would be the best approach to handle them? microflow regex or custom JavaScript or any other easy way that can be applied on all the text fields instead of addressing one at a time. 
asked
1 answers
0

Hi Pranay Kondai,

 

You can use javaScript...

 

$('.validatetext').keyup(function(e){

var $parentDiv = $('.validatetext').closest('.validatetext');
var mytext = $parentDiv.find('.form-control').val();
var alphanumers = /^[a-zA-Z0-9]+$/;
 length = mytext.length-1;
if(!alphanumers.test(mytext)){
  
 $parentDiv.find('.form-control').val( mytext.substr(0,length));

}

});

answered