HTML text box should only accept numbers and dot

|
| By Webner

You can use the following javascript code to check textbox value:

<html>
<head>
<script language="Javascript">
function isNumberKey(evt)
{
var re=new RegExp(/^[0-9]*.?[0-9]*$/);
if(document.getElementById("text").value.match(re))
{
alert("match");
}
else
{
alert("no match");
return false;
}
}
</script>
</head>
<body>
<input id="text" type="text" value="0" name="text" >
<button id="b1" onclick="return isNumberKey(event)" name="btn" type="submit">Save
</html>

Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need Web development or any other software development assistance please contact us at webdevelopment@webners.com

Leave a Reply

Your email address will not be published. Required fields are marked *