To set the color when loading the page, you can do the following.
$(function(){ $('#ID for _userName').css('border-color', color); });
For the color of the border, like everyone else, but it must be presented in shape.
<form ... onSubmit="ValidateUser(this)"> ... Your form elements ... </form>
And your JS will look like this
function ValidateUser(frmObj){ if (frmObj._userName.value.trim() == "") { errMsg += "\nUserName is a mandatory field."; $('#ID for _userName').css('border-color', color); } else { $('#ID for _userName').css('border-color', ''); } }
I also suggest the same class creation logic as Veera, and use that.
Aamir mahmood
source share