All posts by David

Object Oriented Scripting

One of the classes we offer in the web and graphic design program at the Art Institute of Dallas is the Object Oriented Scripting class. We are hoping to use jQuery to demonstrate basic principles of JavaScript objects, including properties, methods, and inheritance. jQuery is a neat JavaScript library that is especially good at manipulating the HTML structure of a page and changing the CSS on the fly. It uses selectors in a similar fashion to CSS. For example to select an element that has the id=”para”, jquery would do something like this:

$(‘#para’).hide();

The $ is simply a variable that represents the jquery object. You could instead type

jquery(‘#para’).hide(); *see my note at bottom

but using the $ instead of jquery is much faster.

Notice the parenthesis that come after $

$(‘#para’)

they contain the selector. In this case we are selecting the element that has the id of para. jQuery will then do something with that element. (An element is another way to say a tag.)

Once jQuery has selected the element it will do something to it. In this case we call the hide method to hide the element. It will disappear!

You can learn more about JavaScript and jQuery along with HTML5, CSS, and JavaScript in our graphic and web design major at AI Dallas. Feel free to contact me for more information: dprince@aii.edu

*to perform this same action in JavaScript you would do:

var para = document.getElementById(‘para’);
para.style.display=’none’;

Input Validation

So last post I put up a link to a regex builder. What would you want to use a regular expression for? Regular expressions let you determine if a pattern of characters is a match. So you can test to see if a set of characters is numeric. A simple use for this would be to check to see if a telephone number typed into a form is a number and not letters. Or another way to say the same thing, is you can use a regular expression to check to see if input is valid.

In the example I just gave, the validation is primarily for the benefit of the user. We don’t want them to make a mistake when they type in the phone number, so we check it for them.

However input validation is a very important part of programming in general for security reasons. Anywhere there is input into a program, a text box on a web page for example, it is a place for someone to attack that system. In general, if there is no place to log in, there is no place to attempt to guess a password. However, user input is a critical part of computer applications.

Knowing that, we have to take precautions against malicious users who may try to use our inputs to inject harmful information such as foreign code into our system. One way to test input to make it is valid, is to use regular expressions as part of input validation.

Web Research

At the Art Institute of Dallas, I taught web design and development. One thing about teaching technology is that it is a moving target. Just when you have mastered one technique, another comes into vogue. I thought I might use this blog, since it was just here laying around doing nothing, to keep up with some of the research I do. Some of the topics I am interested in are basic. Things like HTML5, CSS, and JavaScript. Others are general, like interface design and user experience. Still, others are more technical, like AngularJS MVC.

Speaking of Angular, I can go ahead and put this blog to work. I was interested to see if there was any critique of Angular on the web. I found one and it discussed the crossover between presentation languages and behavioral languages. It was interesting, but more interesting to me was that the author is in the process of creating an alternative to angular called jqcomponents and is based on jQuery. I want to give that a try. The link is here: jqcomponents