2016-08-07 8 views
0

私はこれをスタイルの他の面を変更するために使用しましたが、何らかの理由で入力フィールドの色を変更しません。 style.background-colorのように変更することは可能ですか? "red "; ? 他の質問は、実際のテキストボックスではなく、自分のエラーメッセージが強調表示されている場所を作るようです。CSSを使用して入力テキストフィールドの色を変更するにはどうすればよいですか?

JS

if (document.getElementById("telno").value == /^\d+$/) { 
      document.getElementById("errtelno1").style.display = "inline"; 
      document.getElementById("errtelno1").style.visibility = "visible"; 

これは瞬間

.error{ 
display: none; 
color: #FF2121; 
font-family: arial; 
font-size: 14px; 
font-weight: bold; 
} 

h1{ 
font-style: normal; 
font-weight: bold; 
font-size: 20px; 
font-family: Lucida Sans Unicode; 
color: #0A032F; 
text-align: center; 
text-decoration: underline; 
} 

h2{ 
font-weight: bold; 
font-size: 18px; 
font-family: arial; 
color: #33257B; 
text-align: center; 
text-decoration: underline; 
} 

p{ 
font-family: arial; 
font-size: 14px; 
} 

fieldset{ 
margin-left: 400px; 
margin-right: 400px; 
margin-top: 40px; 
text-align: center; 
border: 1px solid #000000; 
background: linear-gradient(#ffffff, #f2f2f2); 
}  


label{ 
font-family: arial; 
font-size: 14px; 
display: inline; 
} 

.formfield{ 
margin-left: 25px; 
display: inline; 
} 

#title{ 
margin-left: 25px; 
display: inline; 
} 
+0

これは、実際の入力フィールドのテキストボックスではなく、次のエラーを空白にしているようです。 – Jiyl

答えて

1

でCSSではいますが、

document.getElementById("errtelno1").style.backgroundColor ='red';

希望、これを試すことができますこれは役に立ちます!

関連する問題