<!DOCTYPE html>
<html>
<body>
<p id="demo">Click the button to display the third character of a string.</p>
<button onclick="alphanumeric()">Try it</button>
<script type="text/javascript">
function alphanumeric()
{
var inputtxt="1Hello";
var letterNumber = /^[0-9a-zA-Z]+$/;
if(letterNumber.test(inputtxt))
{
alert('OK');
}
else
{
alert("message");
return false;
}
}
</script>
</body>
</html>
<html>
<body>
<p id="demo">Click the button to display the third character of a string.</p>
<button onclick="alphanumeric()">Try it</button>
<script type="text/javascript">
function alphanumeric()
{
var inputtxt="1Hello";
var letterNumber = /^[0-9a-zA-Z]+$/;
if(letterNumber.test(inputtxt))
{
alert('OK');
}
else
{
alert("message");
return false;
}
}
</script>
</body>
</html>