<form name="form" method="post" onsubmit="return validate();"> Enter Decimal Number:<input type="text" name="num"> <input type="submit" value="Check"> </form>
<script type="text/javascript" language="javascript"> function isDecimal(str){ if(isNaN(str) || str.indexOf(".")<0){ alert("Invalid"); } else{ str=parseFloat(str); alert ("Entered number is decimal") } } function validate(){ var dec=document.form.num.value; if (dec == ""){ alert("Please enter."); form.num.focus(); return false; } if (isDecimal(dec)==false){ num=""; form.num.focus(); return false; } return true; } </script>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)