Home > Article > Web Front-end > Only numbers are allowed to be entered in the input box (positive and negative with decimals), and when entering positive numbers, the numbers are red and negative numbers are green_html/css_WEB-ITnose
Thinking of using onkeyup or some other method to achieve it. Ask God for answers.
This involves js.
For events, just use onkeyup of the keyboard key event.
When the button is lifted, a judgment is made in the event processing function: whether the first character in the input box is "-", if the value of the color attribute of the style attribute of the input element is modified, it is green, otherwise it is red. . If it is jQuery, just set the .css() method
and it only needs to be judged once during the continuous input process.
This involves js.
For events, just use onkeyup of the keyboard key event.
When the button is lifted, a judgment is made in the event processing function: whether the first character in the input box is "-", if the value of the color attribute of the style attribute of the input element is modified, it is green, otherwise it is red. . If it is jQuery, just set the .css() method
and it only needs to be judged once during the continuous input process.
This involves js.
For events, just use onkeyup of the keyboard key event.
When the button is lifted, a judgment is made in the event processing function: whether the first character in the input box is "-", if the value of the color attribute of the style attribute of the input element is modified, it is green, otherwise it is red. . If it is jQuery, just set the .css() method
and it only needs to be judged once during the continuous input process.