这不是重复的,我做了很多研究,发现没有什么适合我的东西,我需要我的输入字段边框颜色在每次检测到特定输入时更改,但它不起作用。这里
编辑:修复了一些愚蠢的错误
function zmenitBarvu() {
var inputVal = document.getElementsById("cisla");
if (inputVal.value == "0") {
inputVal.setAttribute( 'style', 'border: 5px solid #f5d442 !important;');
}
if (inputVal.value == "2") {
inputVal.setAttribute( 'style', 'border: 5px solid #f5d442 !important;');
}
else {
inputVal.setAttribute( 'style', 'border: 1px solid #ccc !important;');
}
}
请帮忙
这里
<div class="form">
<form id="cisla">
<input name="cislo1" type="text" class="cisla" placeholder="" id="cislo1" autofocus onkeyup="if (/\D/g.test(this.value)) this.value = this.value.replace(/\D/g,'')" oninput="cislo1.value=cislo1.value.slice(0,2)" /><br>
<input name="cislo2" type="text" class="cisla" placeholder="" id="cislo2" /><br>
<input name="cislo3" type="text" class="cisla" placeholder="" id="cislo3" /><br>
<input name="cislo4" type="text" class="cisla" placeholder="" id="cislo4" /><br>
<input name="cislo5" type="text" class="cisla" placeholder="" id="cislo5" /><br>
<input name="cislo6" type="text" class="cisla" placeholder="" id="cislo6" /><br>
<input name="cislo7" type="text" class="cisla" placeholder="" id="cislo7" /><br>
<input name="cislo8" type="text" class="cisla" placeholder="" id="cislo8" /><br>
<input name="cislo9" type="text" class="cisla" placeholder="" id="cislo9" /><br>
<input name="cislo10" type="text" class="cisla" placeholder="" id="cislo10" /><br>
<input name="cislo11" type="text" class="cisla" placeholder="" id="cislo11" /><br>
<input name="cislo12" type="text" class="cisla" placeholder="" id="cislo12" /><br>
</form>
</div>
繁星coding
相关分类