There is nothing wrong with this code, so post it here. The key points I want to express are hidden in the code. Look for it! Copy code The code is as follows: .org/1999/xhtml" > show date <br>name="mark "; <br>function showLastDate() <br>{ <br>alert(name); <br>var reg=/^d{4}/d{1,2}/d{1,2}$/; <br>var inputdate=$("#indate").val(); <br>if(!reg.test(inputdate)) <br>{ <br>alert("please input date like:2013/1/ 14"); <br>return; <br>} <br>var month=parseInt(inputdate.split("/")[1]); <br>if(month>12||month==0) <br>{ <br>alert("please input month range from 1-12"); <br>return; <br>} <br>var showdate=getLastDate(inputdate); <br>$("#lastdate") .val(showdate); <br>} <br>function getLastDate(indate) <br>{ <br>alert(name); <br>var year=parseInt(indate.split("/")[0]) ; <br>var month=parseInt(indate.split("/")[1]); <br>//run nian <br>var isrun=false; <br>if((year%4==0 && year 0!=0)|| year@0==0) <br>isrun=true; <br>switch(month) <br>{ <br>case 2: <br>if(isrun) <br> {return 29;} <br>else <br>{return 28;} <br>case 1: <br>case 3: <br>case 5: <br>case 7: <br>case 8: <br> case 10: <br>case 12: <br>return 31; <br>default: <br>return 30; <br>} <br>} <br> input date:example:2013/1/14 < ;br> input date: