Published by Zaheer
Last month I wrote about regular expressions in Java, today I’ll show you how to use regular expression in JavaScript to validate email address.
Here is the code to validate email address in JavaScript using regular expression.
function validateEmail(elementValue){
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; return emailPattern.test(elementValue); }
Explanation:
The argument to this method is the email address you want to validate.
In the method body we define a variable (’emailPattern’) and assign a regular expression to it.
Email format: The regular expression for email is
Read more…
If you enjoyed this post, make sure you subscribe to my RSS feed!
. Feb 07, 2008
Filed under: Javascript
Published by Zaheer
Today I am announcing a new montly backlink giveaway. Every month I’ll invite bloggers to post a link to one of their favorite posts on their blog. I’ll then compile those links in a post on my blog. It is a win-win situation for all of us. I hope to get more traffic and you get one more avenue to showcase your posts.
Here is how we do it.
In the comments section below enter link to one of your posts on your blog. You have till Friday night to post your comments. I’ll compile all the links and post them on my blog on Monday.
Note: I will not include links to any inappropriate blogs or posts.
If you like the idea go ahead and post your link now and feel free to spread the word among your friends and your blog readers.
If you enjoyed this post, make sure you subscribe to my RSS feed!
. Feb 05, 2008
Filed under: Blogging
Published by Zaheer
A HTML form is a very good channel that you can offer to your visitors to contact you. An aesthetically appealing form encourages user to fill and submit it. It is equally important to make the form as user friendly as possible. Today I’ll share a small JavaScript function that will set the focus on the first editable text field of your form. So when the web page loads the users don’t have to click on the text field. They can just start typing as soon as the form loads.
Here is the JavaScript code.
function setFocus(){
var flag=false;
for(z=0;z<document.forms.length;z++){
var form = document.forms[z];
var elements = form.elements;
for (var i=0;i<elements.length;i++){
var element = elements[i];
if(element.type == 'text' &&
!element.readOnly &&
!element.disabled){
element.focus();
flag=true;
break;
}
}
if(flag)break;
}
}
How to use this script.
Save the script in a text file and name it focus.js.
To use script copy and paste following line into the header section of your form HTML file.
<script type=”text/javascript” src=”focus.js”>
If you saved the focus.js to a separate directory, include the directory with the file name (like src=”js/focus.js”).
Now add
onLoad=”setFocus();”
to the body tag.
Your body tag will become
<body onLoad=”setFocus(’contactForm’);” >
Now when your page loads the focus will be on the first editable textfield on your form.Click here to see an example.
If you enjoyed this post, make sure you subscribe to my RSS feed!
. Jan 30, 2008
Filed under: Javascript
Published by Zaheer
Last week DailyBlogTips invited bloggers to write turtorials as part of DBT’s blog writing contest. I submitted my tutorial about Google Custom Search for blogs. In all, 71 excellend tutorials covering wide-ranging topics from blogging, montezing to health were submitted. This contest not only provided an opportunity for many bloggers to present their posts to a very receptive audience, it also benefited the readers by showcasing 71 very useful tutorials.
The interesting part of this contest is that the participants themselves are the judges. They will vote for best tutorials and the top 3 tutorials that receive most votes will win. Following is the list of my favorite tutorials.
I wish luck to all the participants. Many thanks to DBT for a great contest.
related_posts();?>
If you enjoyed this post, make sure you subscribe to my RSS feed!
. Jan 29, 2008
Filed under: Blogging
Published by Zaheer
AdSense is by far the most popular and easy to use advertisement program for new bloggers. With AdSense you earn money when users click on the ads on your website. But the ads are not the only source of revenue for your blog. You can use AdSense for Search to to increase your revenue. But a better alternative to AdSense search is the Google Custom Search Engine. You can customize Google Search Engine to blend with your blog’s theme. You can also specify whether to search entire web or just your own website. It is more customizable than AdSense search and like AdSense for search you can earn money through Custom Search Engine.
In this tutorial I’ll show you how to setup Google Custom search engine and then incorporate it with AdSense into your WordPress blog.
The tutorial consists of following sections:
To make things little easier I’ve captured screenshots of some of the screens that we will talk about in this tutorial. To view those screenshots click on the thumbnail images in the following sections. For performance issues I did not include the screenshots on this page but provided the links for easy access.
Now let’s get started.
Read more…
If you enjoyed this post, make sure you subscribe to my RSS feed!
. Jan 25, 2008
Filed under: Blogging
Published by Zaheer
If you are thinking of monetizing your new website you should consider imporving your Alexa rank. Most advertisers and advertising serives like Text Link Ads, Sponsored Reviews etc. use Alexa Rank to determine the worth of a link on your web site. Alexa rank is the level of traffic your site received from Alexa toolbar users. The better your Alexa rank is the better price you can get for publishing ads on your website. From Alexa website
What is Traffic Rank?
The traffic rank is based on three months of aggregated historical traffic data from millions of Alexa Toolbar users and is a combined measure of page views and users (reach). As a first step, Alexa computes the reach and number of page views for all sites on the Web on a daily basis. The main Alexa traffic rank is based on the geometric mean of these two quantities averaged over time (so that the rank of a site reflects both the number of users who visit that site as well as the number of pages on the site viewed by those users). The three-month change is determined by comparing the site’s current rank with its rank from three months ago. For example, on July 1, the three-month change would show the difference between the rank based on traffic during the first quarter of the year and the rank based on traffic during the second quarter.
Fortunately, it is not very difficult to improve (manipulate) your Alexa rank. DoshDosh has a list of 20 suggestions to improve Alexa rank. I don’t recommend that you try all 20 of those suggestions. I tried following simple tricks and my Alexa rank improved within weeks.
Read more…
If you enjoyed this post, make sure you subscribe to my RSS feed!
. Jan 16, 2008
Filed under: Blogging
Tags: Alexa, page rank
Published by Zaheer
Regular Expressions offer a concise and powerful search-and-replace mechanism.
They are patterns of characters used to perform search, extract or replace operations on the given text. Regular expressions can also be used to validate that the input conforms to a given format.
For example, we can use Regular Expression to check whether the user input is a valid Social Security number, a valid phone number or a valid email number, etc.
Regular Expressions are supported by many languages. Sun added support for regualer expression in Java 1.4 by introducing java.util.regex package. This package provides the necessary classes for using Regular Expressions in a java application. It consists of following three main classes ,
- Pattern
- Matcher
- PatternSyntaxException
The java.util.regex package has several other features for appending, text replacement, and greedy/non-greedy pattern matching. See the JDK Documentation on java.util.regex to learn more about using regular expressions in Java.
Using this package I created a utility class to validate some commonly used data elements. My FieldsValidation class has following methods: Read more…
If you enjoyed this post, make sure you subscribe to my RSS feed!
. Jan 10, 2008
Filed under: Java
Tags: Java, Phone number, RegEx, Regular Expression, SSN, utility, Validate email
Published by Zaheer
Vector Magic is a Stanford University research project for vectorizing raster (bitmap) images online.
This is a free online tool to convert bitmap images ( JPG, GIF, BMP, TIFF format) to vector images (EPS,SVG, PNG). This tool is similar to Adobe Illustrator’s Live Trace and CorelDRAW’s PowerTRACE but this one is free.
Check out the comparison page to see how this free tool outperforms these two leading commercial products.
The process of vecrotizing (tracing) is simple. You upload your image file and with a click of button you get a vectorized copy of your image. Save the image to your computer and you are done.
VectorMagic use cookies to keep a list of your last 30 images for 30 days.
So you can go back to your images later to view and revectorize them. You can share your images, stored on VectorMagic servers, with other people. You can either share your private link to the images that will enable them to modify the images on VectorMagic servers or just share a view only link.
If you enjoyed this post, make sure you subscribe to my RSS feed!
. Jan 01, 2008
Filed under: Best Sites
Tags: image conversion., Vectorize bitmap images
Published by Zaheer
Code re-usability is one of the many benefits of object oriented programming. For example, in Java if you need to perform email validation in different classes, rather than writing validation code in each class you can create email validation method in one class and then call that method from other classes. Now you have only one piece of code for email validation which is easy to maintain.
Similarly with JDBC, every time you need to access database you have to do following steps: Read more…
If you enjoyed this post, make sure you subscribe to my RSS feed!
. Dec 20, 2007
Filed under: Java
Tags: Java Utility, JDBC
Published by Zaheer
Inspired by a recent post at DailyBlogTips I seriously started thinking about my blogging goals for 2008. Since I just started blogging a few months ago I have a long way to go. Following are some of my objectives that I would like to achieve during 2008. Read more…
If you enjoyed this post, make sure you subscribe to my RSS feed!
. Dec 19, 2007
Filed under: General
Tags: Blogging goals