Javascript examples for RegExp:Match Number
Validation for Positive Integer Only Input with regex
<html> <head></head> <body> <form action="javascript:console.log('submitted')"> <input type="text" name="example" id="example"> <button onclick="powerOf(event)">Submit</button> </form> <script> function powerOf(event) {/*from w ww . ja v a2 s . c om*/ if (!/^\d+$/.test(document.getElementById('example').value)) { event.preventDefault(); } } </script> </body> </html>