Not allowing non-roman characters in comment and title on Champ app.

Using this code will prevent non-roman characters from being added along with preventing copying and pasting as well. Get the ID's or Classes of the input you want to prevent the characters from being typed in.  
  1.  Find the $(document).ready in champ-footer.liquid and paste this code after with the correct classes or ids.
 
let checkExists = setInterval(() => {
 $("Place Classes or ID's Here").on("input", function(){
 var regexp = /^[1-9]\d*(\.\d+)?$/g;

 if($(this).val().match(regexp)){
  console.log("match");
  $(this).val( $(this).val().replace(regexp,'') );
 }
}); 
 clearInterval(checkExists); 
});
 $('Place Classes or ID's Here').on("cut copy paste",function(e) {
e.preventDefault();
});
     

Leave a comment