Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change checkbox required message

I want to change my checkbox required default message.

I am trying with this code but if I check my checkbox then it still shows required message.

my code

<input  required type="checkbox" name="rcheck2" 
oninvalid="this.setCustomValidity('check plz')" oninput="setCustomValidity('')" />

https://jsfiddle.net/6ekk9upz/

like image 940
testset Avatar asked Dec 11 '22 15:12

testset


1 Answers

checkbox inputs don't have the oninput event, they have the onchange event.

Check this:

<form action="" name="formReg" id="formReg" method="post" class="formReg">
  <div class="checkTxt">
    <input  required type="checkbox" name="rcheck1" oninvalid="this.setCustomValidity('check plz')" onchange="this.setCustomValidity('')"/>
  </div>
  <div class="checkTxt">
    <input  required type="checkbox" name="rcheck2" oninvalid="this.setCustomValidity('check plz')"  onchange="this.setCustomValidity('')"/>
  </div>
  <div class="checkTxt">
    <input  required type="checkbox" name="rcheck3" oninvalid="this.setCustomValidity('check plz')" onchange="this.setCustomValidity('')"/>
  </div>
  <input type="submit" name="btnReg" value="Submite"/>
</form>
like image 136
Dekel Avatar answered Dec 26 '22 10:12

Dekel