Skip to content

Codepolice

  • ⤫

Using JQuery Validation plugin with ASP.NET

Posted by Judy Alvarez Posted on February 25, 2022March 1, 2022
0

Like everyone else, I’ve been playing around with JQuery a lot lately. Asp.net and JQuery are not the best friends in the world but I guess it will be a lot better when using ASP.NET MVC. Microsoft also announced that they will support JQuery natively in future versions. Nice!

If you want to learn more about ASP.NET and Jquery be sure to read both Rick Sthral’s and the Encosia blogs.

I’m working on a new project now where I am trying to stay away from asp.net ajax mainly because of performance reasons but also just because I want to learn something new. Today I’ve been using the JQuery Validation plugin.

There is a lot of documentation on how to use it on the documentation pages for the plugin but I want to share with you one thing that I had problems with.

This is some regular example code that all the samples use. The problem here is that for example “EmailTextbox” is not the ID of the control but the name.

$(document).ready(function() {
// validate signup form on keyup and submit
$("#aspnetForm").validate({
   rules: {
       OpenIdTextbox: "required",
       NicknameTextbox: {
          required: true,
          remote: "resources/nickname.aspx"
          },
       EmailTextbox: {
          required: true,
          email: true
          }
       }
    });
});

I scratched my head for a long long time when I used ctl00_ContentPlaceHolder1_EmailTextbox and nothing worked at all. So what you have to do is change this to something like this.

$(document).ready(function() {
 // validate signup form on keyup and submit
 $("#aspnetForm").validate({
     rules: {
         ctl00$ContentPlaceHolder1$OpenIdTextbox: "required",
         ctl00$ContentPlaceHolder1$NicknameTextbox: {
             required: true,
             remote: "resources/nickname.aspx"
         },
         ctl00$ContentPlaceHolder1$EmailTextbox: {
             required: true,
             email: true
         }
     }
 });
});

You could of course also use some method that rewrites the Control.UniqueID to a name and use <%= %> to get the name of the control.

Categories: JavascriptTagged: asp .net interview questions, asp net authentication, asp net controls, asp net core 1.0, asp net core logging, asp net core middleware, asp net core mvc tutorial, asp net developer, asp net features, asp net interview question, asp net interview questions for 10 years experience, asp net interview questions for 5 years experience, asp net là gì, asp net latest version, asp net machine account, asp net meaning, asp net mvc interview question, asp net mvc tutorial step by step for beginners with examples, asp net project, asp net projects, asp net session, asp net version, asp net web api tutorial, asp net web services, asp net webservice, difference between asp net and asp net core, learn asp net, session asp net, webservices in asp net, what is asp net core

Post navigation

Previous Previous post: Create a tag cloud with a limited amount of tags in ASP.NET and LINQ
Next Next post: Join and Group By with LINQ to Entities

Related Posts

  • What’s next for JavaScript frameworks in 2026

    #​770 — January 27, 2026 Read on the Web JavaScript Weekly Introducing LibPDF: PDF Parsing and Generation from TypeScript — LibPDF bills itself as ‘the PDF library TypeScript deserves’ and supports parsing, modifying, signing and generating PDFs with a modern API in Node, Bun, and the browser. GitHub repo. Documenso JavaScript Frameworks – Heading into 2026

    Posted by Posted on January 27, 2026
    0
  • require(esm) now stable in Node 25

    #​608 — January 22, 2026 Read on the Web Node.js 25.4.0 (Current) Released — Another gradual step forward for Node with require(esm) now marked as stable, as well as the module compile cache, along with a variety of other minor tweaks. Joyee Cheung of the Node team has written a thread on Bluesky going deeper

    Posted by Posted on January 22, 2026
    0
  • A big week for jQuery

    #​769 — January 20, 2026 Read on the Web JavaScript Weekly jQuery 4.0 Released — 20 years on from its original release, the ever-popular (in terms of actual usage) library reaches 4.0 with a migration to ES modules (compatible with modern build tools) along with dropping support for IE 10 and older. With jQuery being

    Posted by Posted on January 20, 2026
    0
  • A new guide to configuring Node packages

    #​607 — January 15, 2026 Read on the Web ⚠️ The Node.js January 13, 2026 Security Releases — Originally expected in December, these releases (of Node.js 25.3.0, 24.13.0, 22.22.0, and 20.20.0) finally landed this week, largely due to their complexity and the scope of the vulnerabilities they tackle. More on that in the next item! The Node.js

    Posted by Posted on January 15, 2026
    0
  • Can we ever fix the web dependency mess?

    #​768 — January 13, 2026 Read on the Web JavaScript Weekly Web Dependencies are Broken; Can We Fix Them? — Lea, who has worked at the heart of Web Standards for years, delivers a compelling (and educational) call to action about a problem every JavaScript developer has encountered: why is managing dependencies and introducing them

    Posted by Posted on January 13, 2026
    0
  • The story of how require(esm) became stable

    #​606 — January 8, 2026 Read on the Web 🎉 Happy New Year! Also, a quick reminder that Node Weekly is now sent every Thursday as part of a reshuffle for many of our newsletters. __Your editor, Peter Cooper npm to Implement ‘Staged Publishing’ After Turbulent Shift Off Classic Tokens — 2025 was a tricky year

    Posted by Posted on January 8, 2026
    0
Judy Alvarez

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Codepolice

  • Github
  • Atlassian
  • Flatlogic
  • Xero
  • Jetbrains
  • Figma
  • What’s next for JavaScript frameworks in 2026
  • require(esm) now stable in Node 25
  • A big week for jQuery
  • A new guide to configuring Node packages
  • Can we ever fix the web dependency mess?
https://flatlogic.com/generator
COPYRIGHT © 2026 - Codepolice