how to change a form background color using jquery while using input[type=text];

refnumbroma

New Member
I know my title my be a little confusing, maybe someone can suggest a different one.So anyways, i am learning some Jquery, i want to us it for form validation, I'll show the code then asked the question.Form:\[code\]<form action="" method="POST"> <ul> <li> <label for="market_1">Market: </label> <input type="text" name="market_1" id="market_1" /> </li> </ul></form>\[/code\]JS:\[code\]$(document).ready(function(){ $("#market_1").addClass("text_box_error");});\[/code\]CSS:\[code\]input[type="text"]{ background-color: rgba(255, 255, 255, 0.5); border: 1px solid #5B5B5B; width: 148px;}input[type="text"]:hover, input[type="text"]:focus { background-color: rgba(255, 255, 255, 1); border: 1px solid #5B5B5B; font-weight: bold;}.text_box_error { background-color: red;}\[/code\]At the moment, i've just trying to get it to change colour when i click the submit button. Now i can get this to work, but i can't get it to work when i using \[code\]input[type="text"]\[/code\] to style the input boxes.I thought by doing that i can style all the input boxes the same and then using the jquery addClass method i can override the background colour.So why doesn't this work with the set up i have shown you?EDIT:Sorry i have updated the code and pasted the wrong version here, i have no updated the code.
 
Back
Top