regular expression validation in asp.net -
i using regular expression validator c# in asp.net login page..i have different login pages student,lecturer , admin..the login ids of form 1rnxxcsxxx,1rnlecsxxx,1rnadcsxxx respectively(x-digits) problem validates text box , displays error message.. still continues n logs in..my code is..
<asp:regularexpressionvalidator id="regularexpressionvalidator1" runat="server" controltovalidate="textbox1" errormessage="enter in 1rnxxcsxxx format" validationexpression="[1][r][n][0-9][0-9][c][s][0-9][0-9][0-9]"></asp:regularexpressionvalidator>
ie..if type lecturer id in student login page can still login inspite of gettin error message..any appreciated.thank u
it seems name of textbox you're using custom login logic. suggest using membership provider more robust in securing entire application. check out how configure member ship database other aspnetdb
for immediate problem though in method logs user in check if page valid.
if( !page.isvalid ) { return; }
more information can found here: this link
also regular expression incorrect. use following successful match.
^1rn([0-9]{2}|le|ad)cs[0-9]{3}$
the expression above says string should start (^ signifies start) 1rn have 2 digits or le or ad followed letters cs , 3 digits ($ signifies end).