Validators not working in asp.net -


i need use 2 validations same textbox(which accepts academic year name input):

  1. regular expression validator allow name entered in format yyyy-yy. have got working :

    <asp:regularexpressionvalidator id="txtacademicyearname_regularexpressionvalidator2" runat="server" controltovalidate="txtacademicyearname" errormessage="enter academic year name in format yyyy-yy" validationexpression="(\b19|\b20)\d\d-\d\d" forecolor="red" display="none"  validationgroup="academicyear"></asp:regularexpressionvalidator> 
  2. when user enters year name, value should greater value( eg. 2012-13 correct, 2013-12 wrong). have added client validation function this:

      function checkacademicyear(source, args) {   alert("yeah");   var sacadyearname = document.getelementbyid('<%= txtacademicyearname.clientid%>').value;   var year = new array;   year = sacadyearname.split("-");   var yearstart = year[0];   var yearend = year[1];    var checkyearstart = (sacadyearname.charat(2) + sacadyearname.charat(3));    if (yearend <= checkyearstart) {       arguments.isvalid = false;    }   else {       arguments.isvalid = true;    } 

    }

academicyear popup opens on button click. when enter name in textbox string, opens popup(it should not do) can see regular expression validator's error message in popup.

how both conditions working?

are call validationgroup="academicyear" in button ?

and replace arguments args

if (yearend <= checkyearstart) {       args.isvalid = false;    }   else {       args.isvalid = true;    } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -