//生日 var birthday_string = ''; var re = /^[0-9]+[0-9]*[0-9]*$/ ; var birthday_year = $("#birthday_year").val(); if( birthday_year != ''){ if(!re.test(birthday_year) || birthday_year.length != 4){ layer.msg('出生年填寫不正確',2,8);return false; } birthday_string +=birthday_year; }