<!DOCTYPE html>
<html>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<h1>My Web Page</h1>
<p id="demo" contenteditable>My first paragraph.</p>
<script>
document.getElementById("demo").innerHTML = "Hello Dolly.";
</script>
<script>
$("#demo").keypress(function(e) {
// alert('CLK')
if (isNaN(String.fromCharCode(e.which))) e.preventDefault();
});
</script>
</body>
</html>
Last active
November 11, 2018 06:14
-
-
Save hygull/356d1c5f043b1564d9fb59e58a490272 to your computer and use it in GitHub Desktop.
Allow only numbers in contenteditable
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment