Jquery Function for validation -
i validate textbox accepts academic year input in format yyyy-yy. how write regular expression validation/ jquery client validation function this?
function parsedate() { alert("yeah"); var sacadyearname = document .getelementbyid('<%= txtacademicyearname.clientid%>'); var m = sacadyearname.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/); return (m) ? new date(m[3], m[2] - 1, m[1]) : null; }
try code
<input id="txtdob" type="text"/> <asp:regularexpressionvalidator id="regularexpressionvalidator4" runat="server" forecolor="red" controltovalidate="txtdob" validationgroup="check" errormessage="date format in yyyy-yy" validationexpression="^([0-9]{4})[.--]+([0-9]{2})$"></asp:regularexpressionvalidator>
eidt:
just change , try it
<input id="txtdob" runat="server" type="text" /> <asp:regularexpressionvalidator id="regularexpressionvalidator4" runat="server" forecolor="red" controltovalidate="txtdob" validationgroup="check" errormessage="date format in yyyy-yy" validationexpression="^([0-9]{4})[./-]+([0-9]{2})$"></asp:regularexpressionvalidator> <asp:button runat="server" validationgroup="check" /> </div>
or add line code!
var m = sacadyearname.match(^([0-9]{4})[./-]+([0-9]{2})$);
it's validate :
2013/14 or 2013-14
Comments
Post a Comment