Home > Web Front-end > JS Tutorial > body text

js code that prohibits spaces in submitting form_javascript skills

WBOY
Release: 2016-05-16 17:14:50
Original
1186 people have browsed it

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
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!