HTML text box should only accept numbers and dot

| By Webner

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

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

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

Leave a Reply

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