Skip to main content
July 26, 2011
Question

Radio Button Color change on Validation

  • July 26, 2011
  • 1 reply
  • 1880 views

Hello,

I have a form with many radio buttons on it, along with the other form fields. I have written form validations using Javascript, so that if any form field is left blank and is required, it turns into red upon the form submission. The text and the date fields are turning red on validation. But, I also want the radio buttons to change red upon validation. Is that possible. I am also generating alert text messages upon validation and its working. Just the color of the radio button is the problem.


I really appreciate the help.

Thanks,

Vijay.

    This topic has been closed for replies.

    1 reply

    pyae phyoe shein
    Known Participant
    July 27, 2011

    I don't think you can change border color and background of radio button in Firefox and Chrome. You can only change those elements of radio button in IE as follow.

    <style>

    <!--

         .changeColor {border:1px #f90442 solid; background:#999999; color:#f90442;}

    -->

    </style>

    <script>

         function ChangeRadioButtonColor (Myobj) {

              try

              {

                   Myobj.myRadio.className = "changeColor";

              }     

              catch(err)

              {

                   alert(err.description)

              }

         }

    </script>

    <form name="myForm">

         <input type="Radio" name="myRadio" class="changeColor">

         <input type="button" name="txtSubmit" value="Change" onclick="ChangeRadioButtonColor(document.myForm)">

    </form>