I need to dynamically control the value of the input. If I give a value like -1,600,000, which attribute of the input should be assigned a value in js How can he normally display a #ff0000 of 1,600,000?
style="color:#ff000"
Thank you upstairs, but my intention was not to Write it to death, only when it is judged to be a negative number in js, you can use js to give it a value and display it in red. When it is a positive number, you do not need to use red, and use element.value = 123 like this.
Then when js determines that it is a negative number, use js to set the color='#ff0000' of the style of the text box
First, you get the value passed into the input value. Whether it is a negative value, you can use regular expressions! If it is a negative value, when it returns true, set the style for the current input box you need to set, that is, the value of the color you mentioned
(var formatResult = formatDecimal(unformatNumber(orderNominal) - unformatNumber(totalExecNominal),null,null,0,null)); getElement("total_amount").xxx = formatResult ;
(var formatResult = formatDecimal(unformatNumber(orderNominal) - unformatNumber(totalExecNominal),null,null,0,null));
if (isNaN(formatResult)) {
getElement("total_amount ").value = -formatDecimal(unformatNumber(-orderNominal) - unformatNumber(-totalExecNominal),null,null,0,null));
getElement("total_amount").style.color = '#ff0000';
} else {
getElement("total_amount").value = formatResult;
}