javascript - Radio button validation -


i making form in radio button click event check value of other form's element. want radio checked or unchecked depands upon value of others. html

<input id="pdisplayprice1" name="pdisplayprice" type="radio" value="yes" onclick="displaypriceformat();"> <span class="help-inline">yes</span> <input id="pdisplayprice2" name="pdisplayprice"  type="radio" value="no" > <span class="help-inline">no</span> 

and dispriceformat() function is

function displaypriceformat() {     var areaping = 0;      var areaperunitprice = $("#pperunitprice").val();     if (areaperunitprice != "") {         var areaperunitpriceunit = $("#pperunitpriceunit").val();         var areashow = areaperunitprice + '/' + areaperunitpriceunit         areaping = 1;     }      if (areaping != 0) {         // radio button checked     } else {         //radio button unchecked      } 

i have tried

<input onclick="displaypriceformat(e);"/> <script>  ......   e.preventdefault(); /// return false;  ....... </script> 

i not see html input id : pperunitprice have used in line:

  var areaperunitprice = $("#pperunitprice").val(); 

but think below info :

you can check checkbox checked or not check this:

    if($("#id_of_checkbox").attr("checked")){      //checked     }    else {     //unchecked     } 

you can check check box this:

$("#id_of_checkbox").prop('checked',true); 

you can check uncheck box this:

$("#id_of_checkbox").prop('checked',false); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -