This is similar to radiobutton example explained above.
When a visitor enters information into a web form displayed in a web browser and clicks the submit button, the information is sent to a server where a server-side script or application processes it.
The issue with this is that if you submit the form without checking either radio button, it correctly shows an error message, but only highlights the first radio button.
If you then check the second radio button, the error message goes away, but the first radio button is still highlighted (via the "error" CSS class).
The following function checks whether the texbox with id name1 is empty, if empty it displays a message and highlights that textbox with red color.