ユーザーが最初の数字として 0 を入力できないようにしようとしています。
これは私が持っているコードです
function validate_numberonly(evt)
{
var theEvent = evt || window.event;
var key = theEvent.keyCode || theEvent.which;
key = String.fromCharCode( key );
var regex = /[0-9]|\./;
if( !regex.test(key) ) {
theEvent.returnValue = false;
theEvent.preventDefault();
}
}
これを許可する正規表現は次replace(/[^0-9]/g,'');
のとおりですが、現在の正規表現の代わりにこれを入力してもうまくいかないようです