js判斷錢(qián)格式

字號(hào):


    var str=document.form1.Price.value;
    re=/^([1-9]\d*|0|)\.\d{2}$/
    if(!re.test(str))
    {alert("價(jià)格格式不正確!請(qǐng)?zhí)顚?xiě)比如:1.22");
    document.form1.Price.value="";
    document.form1.Price.focus();
    return false;}