Home >Web Front-end >JS Tutorial >js code that prohibits spaces in submitting form_javascript skills

js code that prohibits spaces in submitting form_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:14:501247browse

When I was working on a project, I used ckeditor on a page, but a problem arose. When I pressed the Enter key wherever there was a text box, it would automatically refresh. Finally, I found a solution:

Copy code The code is as follows:


Just bind it to each input text box, The onkeydown() event.js code determines whether it is 13. The code is as follows:
Copy the code The code is as follows:

function keydown(text){
$j(text).keydown(function(e){
if(e.which==13){
e.preventDefault();
}
});
}

I use jquery. Because many times, we use event events, which are not compatible with other browsers, so we use jquery which Can be used across various browsers
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn