Week 9 – Lab and Team Meeting

admin | WISE
29 Oct 2010

In the lab meeting, we discussed the different issues that the design reviewers were talking about – and how to tackle them.

I was looking at the validation that Daniel did in different pages. What he accomplished in a short while was really amazing, he used Jason’s validation.js code which had different validation methods like checkRange etc.

But what I noticed was, his code was not aesthetically pleasing. It would look like

 if (!LengthValidation(startTimeHour, 1, 2)) {
               showMessage('Start time hour must be of length 1 or 2');
           } else if (!NumberBetween(startTimeHour, 1, 12)) {
               showMessage('Start time hour cannot be less than 1 or greater than 12');

It did the work, but after a lot of ifs, it gets very confusing what is done where. Also his code, it would just show one message at a time, so if you had multiple errors, you would not know about them unless you click on submit multiple times.

So I spent the rest of the lab researching on other jQuery based validation options. The most relevant one for us (and also being the most popular one) was called the jQuery Validation Plugin.

Next day in the team meeting, I worked on getting the code working with ASP.NET

There were couple of issues like: I had put the javascript files in wrong order for example:

<script type = "text/javascript" src = "jquery.validation.js"></script>
<script type = "text/javascript" src = "jquery.js"></script>

The problem with the above markup is that jquery validation requires jQuery and by putting jquery.js after jquery.validation.js the browser did not know what it was talking about! That took a while to figure out – because it looks very obvious but you can’t immediately figure out.

Later I had to figure out how to use selector tags with based items because they had a different name and id.
Normally if you would have something like

<input name = "firstname" />

you would use the jquery selector plugin like

<script type = "text/javascript">
		rules: {
			firstname: "required",
			lastname: "required",
			username: {
				required: true,
				minlength: 2
			},

where firstname would be required. Now based tags were a different story because they would generate HTML on-fly with a different name and ID. After some googling, I found out how to find out the ASP.NET name. <%= firstname.UniqueID %> – <% %> are the ASP tags and .UniqueID is the name it will generate.

So at the end of the lab I got some basic validation working – and my morale about delivering the project was going down because we are getting less work done.

Leave a Reply