1

I have a number input. When the user write a number in it, the background should changes to green. It works fine with English characters but when user writes e.g. Persian numbers, nothing happens. I have another validation on form submit and it also detects the number fields as empty when there are non-English characters in number field.

In windows browsers I can not paste Persian numbers into these fields. Also in android device, only the English keyboard of digits comes up so user can not type persian characters. The problem is only in iPhone users: They can write Persian but the fields looks empty in validations.

$(document).ready(function(){
  $(document).on("change input paste keyup",'.mandatory',function(e){
      if ($(this).val()){
    $(this).css({"background-color":"#b3d9b5"});
 }
 else{
    $(this).css({"background-color":""});
 }
  })
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="number" class="mandatory">
Ali Sheikhpour
  • 10,475
  • 5
  • 41
  • 82

0 Answers0