I have the following css:
.error .form-inline{ border-color: #a94442; -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075); box-shadow: inset 0 1px 1px rgba(0,0,0,.075); }
and the following function:
function myFunction() {
if (year_value == "" && monthDay_value == "" && char_value == "" && rest_value == ""){
alert("ERROR");
$(':text').addClass("error");
document.getElementById("AuthStatus").focus();
}
}
What I am trying to achieve is when the user enters wrong data in the input fields, to highlight the input where the user input the wrong info. However, the addClass()
appears to not work correctly. I also change the css to target the input fields as well but it doesnt work either:
.error input[type="text"]{ border-color: #a94442; -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075); box-shadow: inset 0 1px 1px rgba(0,0,0,.075); }
I am not sure what I am doing wrong. Any help would be appreciated.
Here is the form:
<div class="override_panel-body mobileAdjustments">
<form class="form-inline" id="AuthStatus">
<div class="background-color form-group">
<div class="padding1"><h3 class="fontWeight">Stay Informed</h3></div>
<p style="padding-left:6px !important;">
Lorem ipsum dolor sit amet, ei ubique disputando mea, sit in duis aliquip vivendo. Cum at justo facilisis. His ad nisl reprimique, eos no liber suscipit. Ex sed viderer phaedrum.
</p>
<div class="input-group panel-body" style="padding-left:6px !important;">
<input id="year" type="text" class="" placeholder="XXXX" aria-describedby="basic-addon1" />
<input id="monthDay" type="text" class="" placeholder="XXXX" aria-describedby="basic-addon2" />
<input id="char" type="text" class="" placeholder="XXXX" aria-describedby="basic-addon3" />
<input id="rest" type="text" class="" placeholder="XXXX" aria-describedby="basic-addon4" />
<div class="form-group">
<input id ="auth" class="override_btn btn-info btn-block adjustments" type="submit" value="Submit" onclick="myFunction()" />
</div>
<div class="form-group">
<input id="clear" class="btn btn-light clear" onclick="ClearForm()" type="button" value="Clear" />
</div>
</div>
<p class="pddingBottom" style="padding-left:6px !important;">
Don't have an authorization number? Contact your doctor to get a copy.
</p>
</div>
<h3 class="fontWeight">FAQ</h3>
<p>
Lorem ipsum dolor sit amet, ei ubique disputando mea, sit in duis aliquip vivendo. Cum at justo facilisis. His ad nisl reprimique, eos no liber suscipit. Ex sed viderer phaedrum.
</p>
</form>
</div>