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

May 16, 2016 pm 05:14 PM
space

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 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does a space mean in mysql? What does a space mean in mysql? Jul 20, 2023 pm 05:17 PM

MySQL A space is a special character used to separate keywords, identifiers, values, and other statement elements. Spaces can be used in multiple locations in a SQL statement and usually do not affect the execution of the statement. The purpose of spaces: 1. Used to separate keywords and identifiers; 2. Used to separate operators and values; 3. Used to separate functions, columns and table aliases; 4. Used for indentation and alignment.

The difference between full-width spaces and half-width spaces The difference between full-width spaces and half-width spaces Mar 25, 2024 pm 12:45 PM

The difference between full-width spaces and half-width spaces. When we use word processing software or edit text content, we sometimes encounter the concept of spaces. Space is a very basic element in typesetting and formatting text, but many people may not know the difference between full-width spaces and half-width spaces. In daily use, we may feel that full-width spaces and half-width spaces have different effects in different situations, but we may not be aware of the subtle differences. First of all, the difference between full-width spaces and half-width spaces is the width they occupy.

How to use spaces correctly in Go How to use spaces correctly in Go Mar 29, 2024 pm 03:42 PM

Go language is a simple, efficient, and highly concurrency programming language. It is an open source language developed by Google. In the Go language, the use of spaces is very important, it can improve the readability and maintainability of the code. This article will introduce how to use spaces correctly in Go language and provide specific code examples. Why you need to use spaces correctly In the programming process, the use of spaces is very important for the readability and beauty of the code. Appropriate use of spaces can make code clearer and easier to read, thus reducing

How to replace spaces in vue How to replace spaces in vue Dec 22, 2022 am 09:40 AM

How to replace spaces in Vue: 1. Create a Vue sample file; 2. Replace all spaces through the regular expression "string = string.replace(/\s/g," ");"; 3. Through "console. log(string);" just output the replaced string.

What is the difference between full-width spaces and half-width spaces? What is the difference between full-width spaces and half-width spaces? Mar 15, 2024 pm 03:49 PM

Differences: 1. The display width of full-width spaces is the same as that of Chinese characters, occupying two bytes. You need to use the Chinese input method when inputting, while the width of half-width spaces is half that of Chinese characters, occupying one byte, just press the space key. Can be input; 2. When typesetting text, full-width spaces make the layout more relaxed, while half-width spaces make the layout more compact.

Sharing of practical techniques for replacing spaces in Golang Sharing of practical techniques for replacing spaces in Golang Mar 13, 2024 am 09:15 AM

Title: Sharing practical techniques for replacing spaces in Golang. With the popularity and development of the Internet, program design and development have become more and more important. In the programming process, data processing is a very critical part. When processing text data, you often encounter situations where you need to replace spaces. This article will share how to implement the technology of replacing spaces in Golang and provide specific code examples. Why do I need to replace spaces? Spaces are one of the common special characters in text data. Sometimes we need to replace spaces with other characters or remove spaces.

How to remove consecutive spaces in php How to remove consecutive spaces in php Nov 03, 2022 am 10:16 AM

How to remove consecutive spaces in PHP: 1. Create a PHP sample file; 2. Use the "strip_tags()" function to strip the HTML, XML and PHP tags in the string; 3. Implement it through the "str_replace" and "preg_replace" functions Just delete the consecutive spaces.

How to remove spaces at both ends of string in php How to remove spaces at both ends of string in php Feb 20, 2021 pm 04:22 PM

How to remove spaces at both ends of a string in PHP: 1. Directly use the trim() function to remove spaces at both ends. This function can remove whitespace characters or other predefined characters on both sides of a string. The syntax is "trim(string)"; 2. . Use the trtrim() and ltrim() functions to remove whitespace characters or other predefined characters on the right and left sides of the string respectively. The syntax is "rtrim(ltrim(string))".

See all articles