Page 1 of 1

add mandatory checkbox using javascript

Posted: Wed Sep 18, 2019 2:14 am
by manalidhuri
Capture.PNG
Capture.PNG (2.32 KiB) Viewed 4703 times
I have use this javascript code to add mandatory sign to the checkbox
Code: Select all
if(foreigncurrency=='14')
   {     
   	var h = '<span id="star" style="color:red">*</span>';
    $("#gglchek").find("label").append(h);
   }
  
   else
   {
      var h = '<span id="star" style="color:white">*</span>';
      $("#gglchek").find("#star").remove();
   }
but it will add two * signs as shown in screenshot and i have to remove one * which are mention using arrow.
Is there any way to resolve this issue?
Please help!

Thanks

Re: add mandatory checkbox using javascript

Posted: Wed Sep 18, 2019 10:02 pm
by amosbatto
To remove the other red asterisk in the field's label, you can use control.disableValidation() and
control.enableValidation().

If you don't want to change the required property and just want to remove the red asterisk, then you can hide it like this:
$("#fieldID").find("span.pmdynaform-field-required").hide()
and show it:
$("#fieldID").find("span.pmdynaform-field-required").show()

Re: add mandatory checkbox using javascript

Posted: Sat Sep 21, 2019 12:01 am
by manalidhuri
It didn't work, it is removing both the * sign

Re: add mandatory checkbox using javascript

Posted: Mon Sep 23, 2019 6:49 am
by manalidhuri
Please replay if there is any solution!!!!

Re: add mandatory checkbox using javascript

Posted: Mon Sep 23, 2019 8:20 pm
by amosbatto
If you just want to add/remove a red asterisk in the field's label, then do it this way:
Code: Select all
if (foreigncurrency=='14')
   {     
     var h = '<span id="star" style="color:red">*</span>';
     $("#gglchek").find("span.textlabel").append(h);
   }
   else
   {
      var h = '<span id="star" style="color:white">*</span>';
      $("#gglchek").find("#star").remove();
   }
}

Re: add mandatory checkbox using javascript

Posted: Tue Sep 24, 2019 12:35 am
by manalidhuri
Thank you so much it is working