EasyUI Forum

General Category => General Discussion => Topic started by: Coder on March 19, 2018, 07:05:39 PM



Title: [SOLVED] easyui-textbox disable input invalid chars
Post by: Coder on March 19, 2018, 07:05:39 PM
I can't think of

Code:

 $('#tb').textbox('textbox').bind('keydown', function(e){
  if (e.keyCode == 13){ // when press ENTER key, accept the inputed value.
   $('#tb').textbox('setValue', $(this).val());
   $('#bSubmit').focus();
  }else if(!(/[a-z ]/.test(e.key))) {
     ???????
  }
 });



Title: Re: ueasyui-textbox disable input invalid chars
Post by: jarry on March 19, 2018, 11:52:27 PM
Try this code.
Code:
var c = String.fromCharCode(e.keyCode);
if (!(/[a-z]/i.test(c))){
return false;
}


Title: Re: ueasyui-textbox disable input invalid chars
Post by: Coder on March 20, 2018, 07:08:53 AM
 need lowercase english and space only

Code:
 }else if(!(/[a-z ]/.test(e.key))){
   return false;
 }

work, thnx