Click here to Skip to main content
15,664,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
 I am facing issue for calling webmethod from remote validator in form validation.Please help me to resolve this issue.

Please check my code:



What I have tried:

txtUsername: {
                    verbose: false,
                    validators: {
                        notEmpty: {
                            message: '<%=Resources.LocalizedText.UserNameRequired%>'
                        stringLength: {
                            min: 6,
                            max: 30,
                            message: '<%=Resources.LocalizedText.UserNameAtleastSixChars%>.'
                        regexp: {
                            regexp: /^[a-zA-Z0-9_\.]+$/,
                            message: '<%=Resources.LocalizedText.InvalidCharactersOnlylettersNumAndUnderscores%>'
                        remote: {
                            url: '/BackOfficeOperations/HMS/SimpleHMS.aspx.cs/checkUsername',
                            type: 'POST',

                            message: '<%=Resources.LocalizedText.UserNameAlreadyExists%>',
                            delay: 1000



   public static void checkUsername(string txtUsername)
       var tsvc = new TenantService();
       if (tsvc.UserNameExists(txtUsername))
           HttpContext.Current.Response.Write("{\"valid\": false}");
           HttpContext.Current.Response.Write("{\"valid\": true}");


<input class="form-control" name="txtUsername" />
Updated 7-Apr-17 2:18am

1 solution

url: '/BackOfficeOperations/HMS/SimpleHMS.aspx.cs/checkUsername'

That's not the URL of your page. That's the URL of the code-behind file, which cannot be accessed remotely, and might not even exist if you've compiled your application.

Try specifying the correct URL for your page, by removing the ".cs":
url: '/BackOfficeOperations/HMS/SimpleHMS.aspx/checkUsername'
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900