2013年1月18日 星期五

簡易年月判斷


textbox先限制長度六位

if (strDataYm.Length!=6)
                    {
                        ScriptManager.RegisterClientScriptBlock(this.Page, typeof(Page), "message", "javascript:alert('"日期格式錯誤", true);
                        return;
                    }
                    if (int.Parse(strDataYm.Substring(4, 2)) > 12 || int.Parse(strDataYm.Substring(4, 2)) == 0)
                    {
                        ScriptManager.RegisterClientScriptBlock(this.Page, typeof(Page), "message", "javascript:alert('"日期格式錯誤", true);
                        return;
                    }

沒有留言:

張貼留言