All Things Techie With Huge, Unstructured, Intuitive Leaps

Javascript: Getting Rid of Unwanted Characters in Number Field


I had a field on a web page where a person would fill in their tax rate as a percentage. Of course, people would put in the percent sign ( % ) along with the number and it would choke the web page. So I needed a quick javascript function to strip out unwanted characters, and leave just numbers and the period if it were a decimal number.

Here is the snippet required. I take the form input. The form name is refForm and taxRate is an input value. The ^ is a negation sign in javascript so I am taking everything out except numbers and decimal.

var si = document.refForm.taxRate.value.replace(/[^\d.]/g, "");
document.refForm.taxRate.value = si;

I assign the original value to a variable and then pass the value back to taxRate after the characters are gone.

Easy way to replace all characters and just leave the numbers using javascript.

A NEw PAraDigm in IT ConsULTing

I have been an IT consultant for over 20 years, and the face of it is changing. I've noticed that in this current economy, it is harder to get consulting gigs, they aren't as long term as they used to be and there is downward pressure on per diems.

In a lot of ways, consultants who became full time employees are starting to look a lot smarter than they did ten years ago. They have benefits, generous stock options, paid holidays and access to company pension plans.

The differential gap between consulting per diems and IT salaries is closing rapidly. Is there a different way that consultants can still enjoy the freedom and diversity of experience in consulting and still be rewarded? I believe that I have found a way.

I would like to fictionalize a recent experience to illustrate perhaps a new paradigm in consulting.

A middling player in a major market decided that they needed a technology boost to compete with the big boys and increase their market share. They decided to increase their presence by using a mobile app that would make the delivery of their products and services less expensive.

Going to a major IT development shop, they were quoted $300,000 to develop their custom app. Approaching a private consultant who was experienced and capable, this consultant offered to develop the app for 10% of the quote ($30,000) and 25% of the net profits that the app generated.

This worked out well. A gig of several months is now providing recurring income two years after the development cycle, and our consultant is on his second project where he is sharing the development costs, the risks and also the profits.

This just might be a new paradigm for IT consultants where they can reclaim the edge that they had over full time IT employees.