Disable single quote Within Forms
This is a good method taught to me by my friend to disable any character in the keyboard Within Forms in your web page/ web application. A simple and effective method to disable specific characters (like single quotes) within form inputs on your webpage or web application.
The Code
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function stopRKey(evt) {
// Normalize the event object
evt = evt || window.event;
// For debugging - shows the keyCode
console.log(evt.keyCode);
// Block single quote (39 or 222 depending on browser)
if (evt.keyCode == 39 || evt.keyCode == 222) {
return false;
}
}
// Attach the event handler to the document
document.onkeypress = stopRKey;
</script>
</head>
<body>
<h3>Test Area</h3>
<textarea rows="5"></textarea>
</body>
</html>
How to Test
- Save the above code as an HTML file (e.g.,
disable-quotes.html
) - Open it in your browser
- Try typing a single quote (') in the textarea
- The single quote character should be blocked
This method can be adapted to block any character by modifying the keyCode check in the stopRKey
function.
Comments
UiPath Training in Chennai
UiPath Training in Adyar
RPA Training in Chennai
RPA courses in Chennai
Blue Prism Training in Chennai
AWS Training in Chennai
It looks like you spend a lot of effort and time on your blog.
Best Web Development Training Institute in Bangalore
Web Design And Development Courses in Bangalore
Best Web Designing Training Institute in Bangalore
php training institute in bangalore
best php training institute in bangalore
best php training in bangalore
php training center in bangalore
Oracle Training in Chennai
Oracle Training institute in chennai
Oracle course in Chennai
Embedded Training
LINUX Course in Chennai
Tally Institute in Chennai
Manual Testing Course