Michael Gaigg: Über UI/UX Design


The importance of the JavaScript parseInt radix

Posted by Michael Gaigg


Just recently I had to implement an HTML form that allows users to enter percentage values. Like every good programmer I added client-side validation to check that the input values are between 0 and 100.

Using the JavaScript function parseInt(txtValue) with txtValue being the value of the input field our tester was able to submit the form with a value of 0137.

My first reaction was to restrict the maxlength attribute of the input field to 3 characters only. Even though this is a good and recommended practise there was clearly something else wrong.


The parseInt() function parses a string and returns an integer. The signature is parseInt(string, radix) with

  • string (required) being the string to be parsed, and
  • radix (optional) a number (from 2 to 36) that represents the numeral system to be used

If the radix parameter is omitted, JavaScript assumes the following:

  • If the string begins with “0x”, the radix is 16 (hexadecimal)
  • If the string begins with “0”, the radix is 8 (octal)
  • If the string begins with any other value, the radix is 10 (decimal)


So, what happened? Because I forgot to specify the radix and our QA tester tried the (however unlikely) case of 0137 JavaScript assumed it was an octal number and returned a value of 95. Lesson learned: Always specify the radix (if it decimal set it to 10 ;)!!!!

PS.: Only the first number in the string is returned!
PPS.: Leading and trailing spaces are allowed.
PPPS.: If the first character cannot be converted to a number, parseInt() returns NaN.


What is Accessibility?

Posted by Michael Gaigg

The purpose of web pages is to interactively display information. The Hypertext Markup Language was designed to encode meaning rather than appearance. Therefore

Accessibility is the extent of access to information on a webpage through user agents (e.g. browsers, screen readers,…) which translate HTML into hypertext structures (links, headers, tables, forms,…) in order to give the users a surplus value.

“As long as a page is coded for meaning, it is possible for alternative browsers to present that meaning in ways that are optimized for the abilities of individual users and thus facilitate the use of the Web by disabled users. Those disabilities are:

  • Visual Disabilities
  • Auditory Disabilities
  • Motor Disabilities
  • Cognitive Disabilities” [NIELSEN96]

Since Web pages are highly visual and interactive the most affected groups as far as accessibility is concerned are the visual disabled, i.e. blind users or users with other visual disabilities like color blindness and users with motor disabilities using alternative input devices or sometimes even just the keyboard instead of the mouse.

Everybody benefits!

In the same way a sidewalk curb is necessary for wheelchair accessibility it also benefits parents with strollers, children with rollerblades and elderly persons trying to cross the street. The same is true for web pages. Designing for accessiblity will not only benefit users with disabilities but will also increase your:

  • Market Share Benefits
    • SEO (search engine optimization)
    • Repurpose
    • Literacy
    • Bandwidth
  • Technical Efficiency Benefits
    • Maintenance
    • Server Bandwidth

Visual Web Design

Posted by Michael Gaigg

First impressions matter! Luke Wroblewski, an excellent speaker with original insights which I had the pleasure to hear at last year's UI-12 (User Interface 12) in Boston, states in his latest article that users coming to your site from a search engine will do one of three things:

  • Look over the page and determine it is not relevant to their goal
  • Look over the page and determine it might be relevant to their goals then quickly scan the page for the information they need
  • Look over the page, quickly scan the page, find the information they need and then stay awhile.

All this happens within seconds. Therefore it is necessary to translate the first impressions (what am I looking at? functional role present?) into meaningful interactions, i.e. scanability, further (inter)action, which leaves us with the following

Guidelines for Visual Web Design

  1. Set initial expectations by communicating what kind of information it provides.
  2. Provide a way to quickly scan that information in order to locate something of value.
  3. Allow people to immerse themselves in the information they want and explore other relevant information when they choose to.
Suggested reading:
Page 24 of 24« First...10...2021222324