Skip to main content

Password Checking with Dojo

If you're puzzling over how to create the usual password and confirmation fields using Dojo,  try out this approach that I came up with for a project I'm working on:

var passwordCheck = new ValidationTextBox({
 id: "password-check",
 placeholder: "Password again...",
 type: "password",
 intermediateChanges: true,
 invalidMessage: "The value you have entered does not match the password you have chosen..."
});
this.password = new ValidationTextBox({
 name: "password",
 id: "password",
 placeholder: "Password...",
 type: "password",
 intermediateChanges: true,
 onChange: function () {

  passwordCheck.set("pattern", this.value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
  if(passwordCheck.value) {
   passwordCheck.validate();
  }

 }
});

It's really simple and keeps everything lean, relying on as little implementation code as possible.  Simply put, every time the password field changes, assign a new escaped validation string to the check field.  It also makes sure to trigger a validation on the check field just in case there's already a value there.

While my example is programmatic, I'm sure there's a declarative equivalent that can be easily derived from my approach here.

I can only imagine how confusing some of the equivalent jQuery solutions to this problem are!

Popular posts from this blog

Amazon in Winnipeg?

Late last week, Amazon put word out that they're starting to look for a city to locate a second headquarters.  The fuel this announcement provides has the hype train in Winnipeg going so fast, it's missing stops.

I'm curious though.  As you've been digesting this exciting news, who have you spoken or listened to?
Was it this guy and his party's historic theft of public infrastructure (pdf) and incompetence with digital strategy? Or how about this guy, who maintains that Winnipeg doesn't need a proper rapid transit option?  You know, the kind that might actually catch the eye of handsome Amazon who now has Winnipeg trying to be the belle of the ball.


Runner up articles are Winnipeg's inability to join the 21st centry on active transport and the compounding of the aforementioned digital strategy mistakes.
Stop Listening to These Guys They are not technology experts. At worst, they're unabashed self promoters. At best they're conduits for very bad pol…

Laravel Project Architecture: The Missing Guide

At my job, we've been doing a lot of learning and development using Taylor Otwell's Laravel 4 PHP framework.  As we've become more familiar with it, we've had to come up with better ways to structure our projects outside of what the documentation indicates and the default distribution that is provided.

If you've been working with Laravel 4 for any amount of time or come with experience from another framework and are just getting started, you've probably noticed that there are a lot of different ways to cut up your projects.


Choice is nice, but sometimes it can be paralysing or misleading. Concrete Advice This post is done in such a way that you can just skim the headings, but if you want a detailed explanation in each section, feel free to read in where necessary.

While I can't say the entirety of my advice is in practice throughout the community, I can say that we are starting to use it, and to very good effect at my job.  Especially considering that our a…

Building .NET Core Nuget Packages

My last blog post was on building and publishing npm packages, specifically for typescript projects. In my opinion, packages are an important fundamental unit in software development. They sit at the confluence of technical competence and collaboration, and represent something the software community should be proud of.
Most of the time, you're going to be creating software packages once you're comfortable with some essential pillars: CodingProject structureSoftware architectureBuildingDeliveryCommunityLicensing
After I got my npm package up and running, my next task was to do the same thing with my C# libraries. Similar to protoculture, I have made a library called praxis.  This is done by leveraging the services and tooling known in the .NET ecosystem as nuget.


In this case, praxis abstracts many of the concepts and functionality I require when producing server projects. It builds on top of ASP.NET Core, so in that sense you can almost think of it as a framework-framework. The…