Component: dijit/form/DateTextBox
Requirement: Let the DateTextBox not respond to user input, and the user can only enter the date by clicking the date control.
Web development may encounter such a demand, that is, the DateTextBox component does not allow the user to input, but only allows the user to click to select the date. But dojo doesn’t seem to provide direct attributes like editable to control.
Here is an implementation that can perfectly meet the needs.
Two ways of writing:
1. Declarative:
function forbiddenUserInput(){ return false; return false; } pre>
2. Programming style:
var dateTextBox = new DateTextBox( {/*Other attribute definitions*/ onInput:function(e){return false}}, id);Generally speaking, it uses the extension point of onInput and returns false.
----------------------------------------The latest discovery, above The method can only block the information input by the English input method, but cannot block the information input by the Chinese input method, and will continue to modify it in the future. It is too late today ------------------- ---------------------------------
Write a method to judge Chinese, you may use Get
var a = '3333fff'; if (/[一-龥]/i.test(a)) {alert('There is Chinese'); }else{ alert('No Chinese passed'); }There is also a prohibition on pasting, which should also be considered