Home > other >  The input box and select box tip
The input box and select box tip

Time:09-19

Today teach you some projects often used but don't know of a few small skills, these are my accumulated in constant practice and to find,

A, 23 types of Input is introduced:
Reprint address:
https://blog.csdn.net/qq_36171618/article/details/80802588

Personal supplement:
1, limiting the input box can only input -- -- -- -- -- pure number/characters
The onkeyup="value=https://bbs.csdn.net/topics/value.replace (/^/d/g,") "

Using the onkeyup events, buggy, that is in the condition of Chinese input method, after input Chinese characters enter directly, can direct input letter
. Onchange="value=https://bbs.csdn.net/topics/value.replace (/^/d/g,") "

Use the onchange event, after the input, a result only when the input focus is lost, and not to respond when the input
. The oninput="value=https://bbs.csdn.net/topics/value.replace (/^/d/g,") "

Use the oninput event, the perfect solved the above two problems,
The Numbers: & lt; Input type="text" placeholder="please enter a phone number" the oninput="value=https://bbs.csdn.net/topics/value.replace (/^/d/g,") "& gt;
Chinese characters: & lt; Input type="text" placeholder="please enter the name" onkeyup="this.value=https://bbs.csdn.net/topics/this.value.replace (/^/u4e00 -/u9fa5/g,") "& gt;

More input please refer to:
https://blog.csdn.net/weixin_42220533/article/details/82256381

2, restrictions on input box number digits - digit
Liberation: & lt; Input type="number" &western ninput="if (value. Length> 5) value=https://bbs.csdn.net/topics/value.slice (0, 4) "/& gt;
Effect:

Principle: the above is the oninput method is used to monitor input from the user behavior, when the length is greater than 5, by slice method capture top 5 Numbers,
Input box checkbox type of backfill are chosen automatically and cancellation
Show calendar date code block:

Backfill values for
If (data [0]. ToVoidNo) $(" # ToVoidNo ") [0]. Checked=true;//check whether;

To determine whether a value selected
Var ToVoidNo=$(" # ToVoidNo "), prop (" checked ");//check whether
Effect: click on the selected, click deselect again


Second, the select box
Often can be used in the process of operation code, we select to the selection of database,

For example:
Qualified types in the database table: id=1 qualified qualified value: 80 id=2 unqualified qualified value: 20
So when I was in the query or obtaining data is often pick his ID value, but at the same time we can not get her Name of data values for

1, get the Name method:
Selesct access to key code Name value: $(" id option: selected "). The text (value)

Using the

$(" # TSalary option: selected "). The text (data. TallSalary);

Use this method can obtain his Name value,
Example:
Schedule structure:
Time schedules: ID start time to end time
Effect:

2, remove the select box on the right - small triangle

Key code: - moz - appearance: inherit; - its appearance: inherit;
Use: & lt; Select name="TSalary" id="TSalary" - moz - appearance: inherit; - its appearance: inherit;">
Effect:


Time transformation format: cc=the Convert. ToDateTime (cc). ToString (" yyyy - MM - dd "),
Note: if your date is layui date, you can turn this way
Insert a small point:
Descending order: group by into first: FirstOrDefault ()
Group: group tbAchievement by tbAchievement. UserID into tbStudent
Achievement=tbStudent. OrderByDescending (m=& gt; M. chievement.) FirstOrDefault (). Achievement,
Today is all some daily tips, hope useful to all of you




  • Related