screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> </head> <body> <div id="app"> <h3>Javascript Textbox allow only number</h3> <input type="text" id="numericInput"> </div> <script> var numericInput = document.getElementById('numericInput'); numericInput.addEventListener('input', function (event) { var inputValue = event.target.value; var numericValue = parseInt(inputValue); if (isNaN(numericValue)) { event.target.value = ''; } else { event.target.value = numericValue; } }); </script> <style> #app { margin: 20px; font-family: Arial, sans-serif; } h3 { font-size: 24px; color: #333; margin-bottom: 10px; } input[type="text"] { padding: 10px; font-size: 16px; border: 1px solid #ccc; border-radius: 4px; outline: none; transition: border-color 0.3s ease-in-out; } input[type="text"]:focus { border-color: #4c9aff; } </style> </body> </html>