I am currently working on implementing asp.net's built-in validation feature to indicate required fields, but I want to take it a step further by not only displaying a message but also changing the background color of the parent div containing the invalid element.
It seems like using the ClientValidationFunction
option is the way to go, however, I'm facing some difficulties while trying to make it work.
This is what I've managed to come up with so far...
<asp:TextBox runat="server" ID="myOption" />
<asp:RequiredFieldValidator runat="server"
ID="myOption_req"
ClientValidationFunction="validateMe"
EnableClientScript="true"
ControlToValidate="myOption"
Text="*"
ErrorMessage="Please fill in all required fields" />
Accompanied by the following javascript code:
function validateMe(){
alert("Hello World");
}
I am currently stuck at getting the alert message to show up and haven't been able to proceed with changing the background color of the parent element yet.