Web design tips on form input boxes

Web design tips on form input boxes

This article lists some tips and codes about form input boxes in web design.
1. Dashed box when cancel button is pressed <br /> Add attribute value hideFocus or HideFocus=true in input
2. Read-only text box content

Add the attribute value readonly to the input
3. Prevent the TEXT document from being cleared after going back (the style content can be used as a class reference)

<INPUTstyle=behavior:url(#default#savehistory);type=textid=oPersistInput>
4. The ENTER key moves the cursor to the next input box
<inputonkeydown="if(event.keyCode==13)event.keyCode=9">
5. Only Chinese (flashing)
<inputonkeyup="value=value.replace(/[-~]/g,'')"onkeydown="if(event.keyCode==13)event.keyCode=9">
6. Only numbers (flashing)
<inputonkeyup="value=value.replace(/[^/d]/g,'')"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))">
7. Only numbers (no flashing)
<inputstyle="ime-mode: disabled"onkeydown="if(event.keyCode==13)event.keyCode=9"onKeyPress="if((event.keyCode<48||event.keyCode>57))event.returnValue=false">

8. Only English and numbers can be entered (with flashing)
<inputonkeyup="value=value.replace(/[/W]/g,'')"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))">
9. Block input method
<inputtype="text"name="url"style="ime-mode:disabled"onkeydown="if(event.keyCode==13)event.keyCode=9">
10. Only numbers, decimal points, and minus signs (-) can be entered (no flashing)
<inputonKeyPress="if(event.keyCode!=46&&event.keyCode!=45&&(event.keyCode<48||event.keyCode>57))event.returnValue=false">
11. Only two decimal places or three decimal places can be entered (flashing)
<inputmaxlength=9onkeyup="if(value.match(/^/d{3}$/))value=value.replace(value,parseInt(value/10));value=value.replace(//./d*/./g,'.')"onKeyPress="if((event.keyCode<48||event.keyCode>57)&&event.keyCode!=46&&event.keyCode!=45||value.match(/^/d{3}$/)||//./d{3}$/.test(value)){event.returnValue=false}"id=text_kfxename=text_kfxe>

<<:  CSS to achieve scrolling image bar example code

>>:  MySQL method of generating random numbers, strings, dates, verification codes and UUIDs

Recommend

Docker large-scale project containerization transformation

Virtualization and containerization are two inevi...

CSS flexible layout FLEX, media query and mobile click event implementation

flex layout Definition: The element of Flex layou...

js learning notes: class, super and extends keywords

Table of contents Preface 1. Create objects befor...

About MariaDB database in Linux

Table of contents About MariaDB database in Linux...

Solution to the automatic stop of MySQL service

This article mainly introduces the solution to th...

Win2008 R2 mysql 5.5 zip format mysql installation and configuration

Win2008 R2 zip format mysql installation and conf...

Mysql5.6.36 script compilation, installation and initialization tutorial

Overview This article is a script for automatical...

The difference and choice between datetime and timestamp in MySQL

Table of contents 1 Difference 1.1 Space Occupanc...

Detailed tutorial on installing Docker on CentOS 8

1. Previous versions yum remove docker docker-cli...

How to use css overflow: hidden (overflow hiding and clearing floats)

Overflow Hide It means hiding text or image infor...

Let’s talk in detail about how JavaScript affects DOM tree construction

Table of contents Document Object Model (DOM) DOM...

Learn MySQL database in one hour (Zhang Guo)

Table of contents 1. Database Overview 1.1 Develo...