Skip to content

Instantly share code, notes, and snippets.

@zy108830
Last active July 14, 2017 08:58
Show Gist options
  • Save zy108830/6dfe8e28b013f5445476 to your computer and use it in GitHub Desktop.
Save zy108830/6dfe8e28b013f5445476 to your computer and use it in GitHub Desktop.
setCustomValidity,html5,required,radio
<form>
<input type="radio" id="test" name="test" value="0" oninvalid="this.setCustomValidity('Click me')" onclick="clearValidity();" required>Zero<br>
<input type="radio" name="test" value="1" onclick="clearValidity()" class="wrapper">One <br>
<input type="radio" name="test" value="2" onclick="clearValidity()" class="wrapper">Two <br>
<input type="submit">
</form>
<script>
function clearValidity(){
document.getElementById('test').setCustomValidity('');
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment