Javascript

来源:互联网 发布:读懂中国经济数据 编辑:程序博客网 时间:2024/05/16 01:17

1.从HTMl页面call回到javascript的function

如: <input type="text" name="from" id="from" maxlength="5" placeholder="day-month" title="Optional" onkeyup="checkDate(this)"/>

function checkDate(caller){
var that = $(caller);
if(caller.id == 'from' || caller.id == 'to'){
if(caller.value.match(/^[0-9 -]+$/g)){that.css('border','none');}
else if(caller.value == ""){that.css('border','none');}else{that.css('border','red 1px solid');}
}

0 0
原创粉丝点击