328 Lines of WordPress Ping List for fastest indexing of new post for 2015

Wondering how each website gets their website indexed by Google and other search engine quick and fast? In WordPress, all you need to do is to place these WordPress ping list to the Settings->Writing->Update Services as shown below,

Screen Shot 2015-09-20 at 2.46.24 PM

then copy the list below and paste it into the textarea


http://rpc.pingomatic.com
http://1470.net/api/ping
http://a2b.cc/setloc/bp.a2b
http://api.feedster.com/ping
http://api.moreover.com/ping
http://api.moreover.com/RPC2
http://api.my.yahoo.co.jp/RPC2
http://api.my.yahoo.com/ping
http://api.my.yahoo.com/RPC2
http://api.my.yahoo.com/rss/ping
http://audiorpc.weblogs.com/RPC2
http://bblog.com/ping.php
http://bing.com/webmaster/ping.aspx
http://bitacoles.net/notificacio.php
http://bitacoles.net/ping.php
http://bitacoras.net/ping
http://blo.gs/ping.php
http://blog.goo.ne.jp
http://blog.goo.ne.jp/XMLRPC
http://blog.with2.net/ping.php
http://blog.youdao.com/ping/RPC2
http://blogbot.dk/io/xml-rpc.php
http://blogdb.jp
http://blogdb.jp/xmlrpc
http://blogdigger.com/RPC2
http://blogmatcher.com/
http://blogmatcher.com/u.php
http://blogoole.com/ping/
http://blogoon.net/ping/
http://blogpeople.net/ping
http://blogpeople.net/servlet/weblogUpdates
http://blogping.unidatum.com/RPC2
http://blogpingr.de/ping/rpc2
http://blogroots.com/tb_populi.blog?id=1
http://blogs.yandex.ru/
http://blogsearch.google.ae/ping/RPC2
http://blogsearch.google.at/ping/RPC2
http://blogsearch.google.be/ping/RPC2
http://blogsearch.google.bg/ping/RPC2
http://blogsearch.google.ca/ping/RPC2
http://blogsearch.google.ch/ping/RPC2
http://blogsearch.google.cl/ping/RPC2
http://blogsearch.google.co.cr/ping/RPC2
http://blogsearch.google.co.hu/ping/RPC2
http://blogsearch.google.co.id/ping/RPC2
http://blogsearch.google.co.il/ping/RPC2
http://blogsearch.google.co.in/ping/RPC2
http://blogsearch.google.co.it/ping/RPC2
http://blogsearch.google.co.jp/ping/RPC2
http://blogsearch.google.co.ma/ping/RPC2
http://blogsearch.google.co.nz/ping/RPC2
http://blogsearch.google.co.th/ping/RPC2
http://blogsearch.google.co.uk/ping/RPC2
http://blogsearch.google.co.ve/ping/RPC2
http://blogsearch.google.co.za/ping/RPC2
http://blogsearch.google.com.ar/ping/RPC2
http://blogsearch.google.com.au/ping/RPC2
http://blogsearch.google.com.br/ping/RPC2
http://blogsearch.google.com.co/ping/RPC2
http://blogsearch.google.com.do/ping/RPC2
http://blogsearch.google.com.mx/ping/RPC2
http://blogsearch.google.com.my/ping/RPC2
http://blogsearch.google.com.pe/ping/RPC2
http://blogsearch.google.com.sa/ping/RPC2
http://blogsearch.google.com.sg/ping/RPC2
http://blogsearch.google.com.tr/ping/RPC2
http://blogsearch.google.com.tw/ping/RPC2
http://blogsearch.google.com.ua/ping/RPC2
http://blogsearch.google.com.uy/ping/RPC2
http://blogsearch.google.com.vn/ping/RPC2
http://blogsearch.google.com/ping/RPC2
http://blogsearch.google.de/ping/RPC2
http://blogsearch.google.es/ping/RPC2
http://blogsearch.google.fi/ping/RPC2
http://blogsearch.google.fr/ping/RPC2
http://blogsearch.google.gr/ping/RPC2
http://blogsearch.google.hr/ping/RPC2
http://blogsearch.google.ie/ping/RPC2
http://blogsearch.google.in/ping/RPC2
http://blogsearch.google.it/ping/RPC2
http://blogsearch.google.jp/ping/RPC2
http://blogsearch.google.ki/ping/RPC2
http://blogsearch.google.kz/ping/RPC2
http://blogsearch.google.la/ping/RPC2
http://blogsearch.google.li/ping/RPC2
http://blogsearch.google.lk/ping/RPC2
http://blogsearch.google.lt/ping/RPC2
http://blogsearch.google.lu/ping/RPC2
http://blogsearch.google.md/ping/RPC2
http://blogsearch.google.mn/ping/RPC2
http://blogsearch.google.ms/ping/RPC2
http://blogsearch.google.mu/ping/RPC2
http://blogsearch.google.mv/ping/RPC2
http://blogsearch.google.mw/ping/RPC2
http://blogsearch.google.nl/ping/RPC2
http://blogsearch.google.no/ping/RPC2
http://blogsearch.google.nr/ping/RPC2
http://blogsearch.google.nu/ping/RPC2
http://blogsearch.google.pl/ping/RPC2
http://blogsearch.google.pn/ping/RPC2
http://blogsearch.google.pt/ping/RPC2
http://blogsearch.google.ro/ping/RPC2
http://blogsearch.google.ru/ping/RPC2
http://blogsearch.google.rw/ping/RPC2
http://blogsearch.google.sc/ping/RPC2
http://blogsearch.google.se/ping/RPC2
http://blogsearch.google.sh/ping/RPC2
http://blogsearch.google.si/ping/RPC2
http://blogsearch.google.sk/ping/RPC2
http://blogsearch.google.sm/ping/RPC2
http://blogsearch.google.sn/ping/RPC2
http://blogsearch.google.st/ping/RPC2
http://blogsearch.google.tk/ping/RPC2
http://blogsearch.google.tl/ping/RPC2
http://blogsearch.google.tm/ping/RPC2
http://blogsearch.google.to/ping/RPC2
http://blogsearch.google.tp/ping/RPC2
http://blogsearch.google.tt/ping/RPC2
http://blogsearch.google.tw/ping/RPC2
http://blogsearch.google.us/ping/RPC2
http://blogsearch.google.vg/ping/RPC2
http://blogsearch.google.vu/ping/RPC2
http://blogsearch.google.ws/ping/RPC2
http://blogshares.com/rpc.php
http://blogsnow.com/ping
http://blogstreet.com/xrbin/xmlrpc.cgi
http://blogupdate.org/ping/
http://bulkfeeds.net
http://bulkfeeds.net/rpc
http://catapings.com/ping.php
http://coreblog.org/ping
http://coreblog.org/ping/
http://effbot.org/rpc/ping.cgi
http://feedburner.google.com/fb/a/pingSubmit?bloglink=http%3A%2F%2Fdomainname.com
http://feedburner.google.com/fb/a/pingSubmit?bloglink=http%3A%2F%2Fyourwebsite.com
http://feedsky.com/api/RPC2
http://fgiasson.com/pings/ping.php
http://geourl.org/ping
http://geourl.org/ping/
http://hamo-search.com/ping.php
http://holycowdude.com/rpc/ping
http://holycowdude.com/rpc/ping/
http://imblogs.net/ping/
http://ipings.com
http://lasermemory.com/lsrpc/
http://mapufacture.com/georss/ping/api
http://mod-pubsub.org
http://mod-pubsub.org/kn_apps/blogchatt
http://mod-pubsub.org/knapps/blogchatt
http://mod-pubsub.org/ping.php
http://news2paper.com/ping
http://newsblog.jungleboots.org/ping.php
http://newsisfree.com/RPCCloud
http://packetmonster.net/xmlrpc.php
http://ping.amagle.com
http://ping.amagle.com/
http://ping.bitacoras.com
http://ping.bitacoras.com/
http://ping.blo.gs
http://ping.blo.gs/
http://ping.blogg.de/
http://ping.bloggers.jp/rpc
http://ping.bloggers.jp/rpc/
http://ping.blogmura.jp/rpc/
http://ping.blogoon.net
http://ping.blogoon.net/
http://ping.blogs.yandex.ru/RPC2
http://ping.cocolog-nifty.com/xmlrpc
http://ping.exblog.jp/xmlrpc
http://ping.fakapster.com/rpc
http://ping.fc2.com
http://ping.fc2.com/
http://ping.feedburner.com
http://ping.feeds.yahoo.com/RPC2/
http://ping.groove-cast.com/ping.php
http://ping.kutsulog.net
http://ping.kutsulog.net/
http://ping.myblog.jp
http://ping.namaan.net/rpc
http://ping.pubsub.com/ping
http://ping.rootblog.com/rpc.php
http://ping.rss.drecom.jp
http://ping.rss.drecom.jp/
http://ping.snap.com/ping/RPC2
http://ping.speenee.com/xmlrpc
http://ping.syndic8.com/xmlrpc.php
http://ping.weblogalot.com
http://ping.weblogalot.com/rpc.php
http://ping.weblogs.se
http://ping.weblogs.se/
http://ping.wordblog.de
http://ping.wordblog.de/
http://pinger.blogflux.com/rpc
http://pingoat.com/
http://pingoat.com/goat/RPC2
http://pingoo.jp/ping/
http://pingqueue.com/rpc/
http://popdex.com/addsite.php
http://r.hatena.ne.jp/rpc
http://rcs.datashed.net
http://rcs.datashed.net/RPC2
http://rcs.datashed.net/RPC2/
http://rcs.salon.com/RPC2
http://rpc.blogbuzzmachine.com/RPC2
http://rpc.bloggerei.de/
http://rpc.bloggerei.de/ping/
http://rpc.blogrolling.com
http://rpc.blogrolling.com/pinger
http://rpc.blogrolling.com/pinger/
http://rpc.britblog.com
http://rpc.britblog.com/
http://rpc.icerocket.com:10080
http://rpc.icerocket.com:10080/
http://rpc.newsgator.com/
http://rpc.odiogo.com/ping/
http://rpc.pingomatic.com
http://rpc.pingomatic.com/
http://rpc.reader.livedoor.com/ping
http://rpc.tailrank.com
http://rpc.tailrank.com/feedburner/RPC2
http://rpc.technorati.com/ping
http://rpc.technorati.com/rpc/ping
http://rpc.technorati.jp/rpc/ping
http://rpc.twingly.com
http://rpc.twingly.com/
http://rpc.urlfan.com/ping
http://rpc.weblogs.com
http://rpc.weblogs.com/pingSiteForm?name=YourWebsite&url=http%3A%2F%2Fyourwebsite.com
http://rpc.weblogs.com/pingSiteForm?name=YourWebsite&url=http%3A%2F%domainname.com
http://rpc.weblogs.com/RPC2
http://rpc.wpkeys.com
http://serenebach.net/rep.cgi
http://services.newsgator.com/ngws/xmlrpcping.aspx
http://signup.alerts.msn.com/alerts-PREP/submitPingExtended.doz
http://snipsnap.org/RPC2
http://submitblogs.com/
http://syndic8.com/xmlrpc.php
http://thingamablog.sourceforge.net/ping.php
http://topicexchange.com
http://topicexchange.com/RPC2
http://topicexchange.com/RPC2eping.php
http://trackback.bakeinu.jp/bakeping.php
http://wasalive.com/ping/
http://weblogues.com/ping/
http://weblogues.com/RPC/
http://www.2bet.com/
http://www.2rss.com
http://www.a2b.cc
http://www.a2b.cc/setloc/bp.a2b
http://www.bitacoles.net/ping.php
http://www.blogarama.com/
http://www.blogbits.com/
http://www.blogcatalog.com/
http://www.blogdex.net/
http://www.blogdigger.com
http://www.blogdigger.com/RPC2
http://www.blogexplosion.com
http://www.bloggernity.com/
http://www.bloglines.com/ping
http://www.blogoole.com/ping/
http://www.blogoon.net/ping
http://www.blogoon.net/ping/
http://www.blogpeople.net
http://www.blogpeople.net/ping
http://www.blogpeople.net/servlet/weblogUpdates
http://www.blogpulse.com/submit.html
http://www.blogroots.com
http://www.blogroots.com/tb_populi.blog?id=1
http://www.blogroots.com/tbpopuli.blog?id=1
http://www.blogsdominicanos.com/ping
http://www.blogsdominicanos.com/ping/
http://www.blogshares.com
http://www.blogshares.com/rpc.php
http://www.blogsnow.com/ping
http://www.blogstreet.com
http://www.blogstreet.com/xrbin/xmlrpc.cgi
http://www.blogwise.com/
http://www.catapings.com/ping.php
http://www.feedblitz.com/f/f.fbz?XmlPing
http://www.feedsky.com/api/RPC2
http://www.feedster.com/
http://www.feedsubmitter.com
http://www.globeofblogs.com/
http://www.holycowdude.com/rpc/ping/
http://www.imblogs.net/ping/
http://www.lasermemory.com
http://www.lasermemory.com/lsrpc
http://www.lasermemory.com/lsrpc/
http://www.linksboy.com/
http://www.lsblogs.com/
http://www.mod-pubsub.org/kn_apps/blogchatter/ping.php
http://www.mod-pubsub.org/knapps/blogchatter/ping.php
http://www.mod-pubsub.org/ping.php
http://www.mod-pubsub.orgping.php
http://www.newsisfree.com
http://www.newsisfree.com/RPC
http://www.newsisfree.com/RPCCloud
http://www.newsisfree.com/xmlrpctest.php
http://www.octora.com/add_rss.php
http://www.ohlinks.com
http://www.pingerati.net
http://www.pingmyblog.com
http://www.popdex.com
http://www.popdex.com/addsite.php
http://www.readablog.com/
http://www.rogerlinks.com/linker/index.shtml
http://www.snipsnap.org
http://www.snipsnap.org/RPC2
http://www.syndic8.com/xmlrpc.php
http://www.wasalive.com/ping/
http://www.weblogalot.com/ping
http://www.weblogs.com/RPC2
http://www.weblogues.com
http://www.weblogues.com/RPC
http://www.weblogues.com/RPC/
http://www.xianguo.com/xmlrpc/ping.php
http://www.zhuaxia.com/rpc/server.php
http://xianguo.com/xmlrpc/ping.php
http://xmlrpc.blogg.de
http://xmlrpc.blogg.de/
http://xmlrpc.bloggernetz.de/RPC2
http://xping.pubsub.com/ping
http://xping.pubsub.com/ping/
http://xping.pubsub.comping/
http://zhuaxia.com/rpc/server.php
http://zing.zingfast.com
https://blogs.yandex.ru/pings/
https://ping.blogs.yandex.ru/RPC2

Once you do this, your WordPress new post will ping all the above list so that other search engines are notify and can come fetch your new content asap!

Iphone/Ipad number format css style change in safari

Here's something interesting yet simple to share for a long time. If you are wondering and debugging countless hours for a very simple thing such as color change on a number format in ipad or iphone, you might just arrived to the correct blog post. We all know that debugging CSS and HTML in ipad or iphone isn't an easy task although we can emulate the environment, there are certain things we cannot emulate such as the behavior of the ipad or iphone OS itself. Interestingly, a client of mine faced such issue with their website where his 'contact' number listed on his website was changed to blue instead of white as declared on the css file when view on ipad or iphone.

Now, the odd thing is that even the emulator is showing the colors correctly. Debugged for a few hours without any luck but notice that  whenever i added alphabet into the numbers, it changes back to the correct colors. I though it was some javascript but it wasn't. In the end, i disabled the whole CSS and notice something different on the emulator and the ipad. Weirdly, ipad and iphone treat numbers as a link because it can be a contact on safari. Therefore, it automatically  wrapped around a group of numbers with an anchor link on a web page.  Therefore, your CSS declaration have to write something like

.style{
color: blue
}

and added something like

.style, .style a{
color: blue
}

if you wish to cater to ipad or iphone on your website. Even if you do not have a mobile stylesheet, ipad or iphone will still behave this way. Therefore, for any group of numbers on your website, just take note of such behavior on mobile devices such as iphone or ipad.

21 Tips To Find A Good Shared Web Hosting Company

Recently i was looking for a local shared web hosting company to move my new project from my current host to a local one. Similarly like everyone in the world who wished to look for new things, they would research and so did i. And because of my previous experience on finding my current US web hosting company, hostgator, which is a long and tiring journey due to many fake and incorrect information that people (i can't really really say company) made online for monetary purposes. It's always easy to fall prey into all these online marketing tricks. So i decided to list down all the tips i used to find a good web shared hosting company in the case where i need to change to a new hosting company (hopefully not).

Shared web hosting

Like everyone would have known the fact that a shared web hosting means there are a lot of people sharing a single server with you. Sharing doesn't mean that your website will run slower or it will be worst than a dedicated server. It really depends on your website needs. Your website might be a static page that only needs less than 0.1% (or even lesser) on a full dedicated server so putting your site in a shared environment will be the best in terms of cost and efficient. However, there are cases where people abuse the resources in a shared environment which is also why many web hosting company have turned to restrict the amount of resources one can utilize which is a good move in a shared environment. Hence, your only concern on a shared hosting service is whether people in your server is behaving properly or utilize minimum server resources. (so that there is enough for everyone)

Shared web hosting company

Now let's talk about shared hosting company. There are tons of them. Majority is overselling. These are the facts and most of us know it once we read their shared web hosting plan. Especially in US where majority company is telling you the word UNLIMITED. And DAMN that's a very VERY attractive word that ALL people love. (human have unlimited wants but there are limited resources, eg. we want unlimited beautiful woman but there are only limited beauties) And usually a novice who read the first site that offered UNLIMITED hosting plan will most likely fall into their marketing scheme (ITS YOU RIGHT?! haha..). But its pretty common nowadays especially people who are just stepping into the world of spammers, opps, i mean world of web hosting services. Everyone wants to earn some money and this doesn't exclude shared web hosting company. New or existing shared web hosting company, they all are staring at your pocket. The key is not to show them the money quickly. I talked as if they are all spammers. Definitely, there are ones that provides you with excellent services but out of so many shared web hosting company, who do you choose? 🙁

Tips To Find Good Hosting Company

After the long read of crap and nonsense, i'm finally getting back to what i aim to write, My Tips. Some are obvious, some are not. Just take those you want 🙂

Your Needs. Don't be greedy

I'm greedy. And this is where i always paid more for something i might not EVEN need. It's like when you hungry and order tons of food but couldn't finish them in the end. The same things applied on web hosting service. The trick is to estimate how much you need for both bandwidth and space. For an image gallery where there are few thousands visitors a day. You will need quite a lot of bandwidths while a normal website that doesn't serve as much images won't need that much of space and bandwidths. Hence, look at what you are serving and determine which plan suit you the best. (unlimited packages usually disappoint you more than satisfy you. Depending on the size of the company,  they might not have the resources to provide unlimited package)

Number of Website Hosted in a server

You need to know how much website is hosted in a particular server. If one server hosted more than a thousand websites, the probability of your site getting your resources will be very limited. Imagine more than one thousand website fighting that limited resources in a server. Hence, look for some company that do not over host their server and cause headache for you in the near future.

Number of Account in a server

You might probability be aware that there are a lot of web hosting that claims unlimited web site on a domain. This is great news for everyone but each account with unlimited website will means MANY MANY website on a single server. Therefore, its wise to know more about your web hosting company setting on the number of account allowed per server.

Server Location

Depending who your audiences are, your server should be close or near them. This benefits both you and your target audiences of your website because there are less expensive routing towards your website which makes your website more accessible. On the other hand, you can monitor or manage your website faster than a web hosting companies that is across your region.

Any Database Size Limitation

Know your web hosting company well. Some web hosting company (most) do not tell you the limitation they impose on the database size. Once, you reach that limit that database can no longer place more data into it. This is bad for you and you should be aware of it before signing up with them.

CPU and Memory Limitation

CPU and memory limitation is a common knowledge in shared web hosting nowadays. As long as you are using a shared web hosting service, you should be aware of this limitation. Knowing this help you to find the least restrictive web hosting company with the best value.

Server Specification

In a shared environment where everyone uses the same resources, one must know that the server is powerful enough to serve the amount of website limited by the company in the server. Some still uses their old server to host the same amount of website as a latest server. You might want to avoid those server to avoid unnecessary problem.

Backup

Knowing when and what they backup is important for you in case anything went wrong with their server. Especially the information on the limitation impose when they stop automatic backup for you. There are many cases where they will stop their automatic backup system for your account due to various reasons. And these reasons might make you avoid the company.

Time of Establishment

A reputational web hosting company means you are safer with them. This means that you can have more confident that they won't suddenly bankrupt and went missing (something you see in my country) and your data won't be stolen because your website did great and many ridiculous problem you might face with a untrusted hosting company (To began with, they do not have any reputation to spoil).

Any limitation on the number of domain/subdomain

If you like to have one hosting plan with multiple domain. You should aware of the number of domain/subdomain the plan offer you to prevent any unnecessary regrets.

Any limitation on each email account size

Some web hosting company impose a maximum email account size limit to prevent spam from over flooding their web server. If you are a person who dislike such restriction be sure to look properly before signing up with any company.

Responsiveness

Another way to know whether they are good is to ask lots of questions and determine their responsiveness and correctness. A responsive and knowledgable support team will most likely make you more happy than angry in the future. Email different section to enquire anything from heaven to earth especially when you are sure ITS THAT COMPANY you want.

Maximum number of database connection

Some company restrict the number of database connection or users you can have. Having unlimited addon domain without having different database user or connection is like cutting your leg off while giving you sticks to walk. Without knowing such limitation and bang into a web hosting services will not do you any good.

Other Service Fees

Some company charge you service fees for some technician assistance. This is an information you should know to help yourself cut down some heavy addon fees on your web hosting when support become chargable. Ask your web hosting services what are chargeable and determine whether its reasonable before joining the club.

Connection

Another interesting thing you should be aware of is the connection speed use to power their web hosting service. Connection is also one of the important thing you would like to compare against different web hosting company.

Technical support, not so technically skill

This is a common scenario where their technical support give you stupid answer or incorrect one. Some even give you those default answers that was given by the company. Finding a good support will take you a long way in the future.

Talk to people

Find out from people who are currently using the company web hosting service. I'm sure they will share with you their experiences with them and you can better determine whether they are the one for you.

Use tool to verify

After you have enquire. You can further verify some of the information given by using some of those free web based tool. I personally used yougetsignal.com where it can tell me the number of website hosted in an IP address, location of the server, etc. This help you ensure that you are not being marketed and they are honest with their words.

Server hosting company

Another thing you might want to check with your web hosting company is their server hosting company. Their downtime depends greatly on them.

Check IP

Check their IP in one of those spam ip checker online. Determine whether their IP is considered as spam is important as many internet provider would block these ip to protect their users. This will also means your website will be considered as spam site.

Other tips

Other tips can be found on my review page on hostgator.

Summary

The trick here is to always ask for information not available on their website. These are most likely the information they wish to hide. But they can always trick you when you ask and that is why money back guarantee is so important to us.

17 JavaScript Form Validation Snippets

Last week i wrote 25 form validation for PHP. I find useful to have more layer of defend as JavaScript might malfunction or disable and cause your validation to fail but the form is still being passed on to our server. Nonetheless, JavaScript validation does provide certain level of restriction and protection for any web application. Especially when web is evolving quickly in this period of time. We are required to validate any data from our user to prevent any harm that can cause damage to our application and businesses. These JavaScript form validation snippets are needed in every form validation and repeating searching for them is unnecessary and slow down development processes. Therefore, you might want to bookmark these snippets for your future needs

Email Validation

Email validation is the most basic validation that any web application would have.

function isEmail(elem, helperMsg){
	var regexp  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(regexp.test(elem.value)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

In order to use this, we pass in an object and an alert value if it fail.

var email = document.getElementById('ham_email');
if(isEmail(email, "Invalid Email Format")){
//proceed..
}

URL Validation

URL validation helps to validate whether a particular string is a valid url format.

function isUrl(elem, helperMsg) {
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	if(regexp.test(elem.value.toLowerCase())){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

In order to use this, we pass in an object and an alert value if it fail.

var link = document.getElementById('ham_link');
if(isUrl(link, "Invalid link")){
//proceed..
}

Username Validation

This function help us validate whether a username contain valid character and length. It accept any underscore, alphabets and numbers within 5-25 characters.

function isValidUsername(elem, msg) {
	var regx = /^[A-Za-z0-9_]{5,25}$/;
	if(regx.test(elem.value)){
		return true;
	}else {
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

You can add additional symbols or change the length of the validation easily by alter the regular expression.

In order to use this, we pass in an object and an alert value if it fail.

var username = document.getElementById('username');
if(isValidUsername(username, "Invalid character found on username!")){
//proceed...
}

Password Validation

Here is a simple password strength validation that check the following criteria.

  1. Passwords will contain at least 1 upper case letter
  2. Passwords will contain at least 1 lower case letter
  3. Passwords will contain at least 1 number or special character
  4. Passwords will contain at least 8 characters in length
  5. Password maximum length should not be arbitrarily limited
function isStrongPassword(elem, msg) {
	var regx = /(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/;
	if(regx.test(elem.value)){
		return true;
	}else {
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

In order to use this, we pass in an object and an alert value if it fail.

var password = document.getElementById('password');
if(isStrongPassword(password, "Your password fail the basic strength test. \n1. Passwords will contain at least 1 upper case letter\n2. Passwords will contain at least 1 lower case letter\n3. Passwords will contain at least 1 number or special character\n4. Passwords will contain at least 8 characters in length\n5. Password maximum length should not be arbitrarily limited\n")){
//proceed..
}

Numeric Validation

This validate whether a given string contain a valid numeric value which include both negative value and decimal ones.

function isNumeric(elem, helperMsg){
	var numericExpression = /^[-]?\d*\.?\d*$/;
	if(elem.value.toString().match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

In order to use this, we pass in an object and an alert value if it fail.

var price = document.getElementById('price');
if(isNumeric(price, "Invalid value found")){
//proceed...
}

Text Empty Validation

In every form validation, there is always a need to check whether a particular text box is empty.

function isEmpty(elem, helperMsg){
	if(elem.value.toString().length > 0){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

In order to use this, we pass in an object and an alert value if it fail.

var name = document.getElementById('ham_company');
if(!isEmpty(name, "Please give us your name")){
//proceed...
}

Radio Box Validation

We can determine whether a radio box has been selected using this function.

function hasSelected(elem, msg){
	for (i = 0; i < elem.length; i++) //for all check boxes
	{
		if (elem[i].checked == true ) //otherwise elements also looks at radio buttons
		{
			return true;
		}
	}
	alert(helperMsg);
	elem[0].focus();
	return false;
}

Drop Down Validation

We also check whether a particular drop down box has its value selected with the following function.
In order to use this, we pass in an object and an alert value if it fail.

var radio = document.getElementById('radio');
if(hasSelected(radio, Please select your gender")){
//proceed...
}
function isSelected(elem, helperMsg){
	if(elem.options[elem.selectedIndex].value.toString().length > 0){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

In order to use this, we pass in an object and an alert value if it fail.

var month = document.getElementById('ham_month');
if(isSelected(month, "Please select a month")){
//proceed...
}

Check Box Validation

We can perform check box validation to see whether a particular check box has been selected through this function.

function hasChecked(elem, msg){
	for (i = 0; i < elem.length; i++) //for all check boxes
	{
		if (elem[i].checked == true ) //otherwise elements also looks at radio buttons
		{
			return true;
		}
	}
	alert(helperMsg);
	elem[0].focus();
	return false;
}

In order to use this, we pass in an object and an alert value if it fail.

var checkbox= document. getElementsByName('checkbox');
if(checkPhone(checkbox, "Please tick one of the check box")){
//proceed...
}

Phone Validation

This function will validate the following criteria phone number.

  • phone:
    339-4248
    339-42-48
    339 42 48
    339 4248
    3394248
    (095) #phone#
    (095)#phone#
    +7 (095) #phone#
    +7 (095)#phone#
    +7(095) #phone#
    +7(095)#phone#
function checkPhone(elem, msg)
{
	var str = elem.value;
	var phone2 = /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/;
	if (str.match(phone2)) {
   		return true;
 	} else {
 		alert(helperMsg);
		elem.focus();
		return false;
 	}
}

In order to use this, we pass in an object and an alert value if it fail.

var phonenumber = document.getElementById('phonenumber');
if(checkPhone(phonenumber, "Invalid Phone Number")){
//proceed...
}

File Extension Validation

This function validate whether a particular upload string contains a valid extension.

function isAllowedFileExtension(elem, helperMsg){
	var alphaExp = /.*\.(gif)|(jpeg)|(jpg)|(png)$/;
	if(elem.value != "")
	{
		if(elem.value.toLowerCase().match(alphaExp)){
			return true;
		}else{
			alert(helperMsg);
			elem.focus();
			return false;
		}
	}
	else
		return true;
	return false;
}

In order to use this, we pass in an object and an alert value if it fail.

var upload = document.getElementById('ham_upload');
if(isAllowedFileExtension(upload, "Please Upload Gif, Png or Jpg Images Files Only")){
//proceed...
}

IP Validation

Sometimes there is a need to validate whether a particular IP address is valid using JavaScript.

function isValidIPAddress(elem, msg) {
   var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
   ipaddr = elem.value.toLowerCase();
   if (re.test(ipaddr)) {
      var parts = ipaddr.split(".");
      if (parseInt(parseFloat(parts[0])) == 0) { return false; }
      for (var i=0; i<parts.length; i++) {
         if (parseInt(parseFloat(parts[i])) > 255) { return false; }
      }
      return true;
   } else {
		alert(helperMsg);
		elem.focus();
		return false;
   }
}

In order to use this, we pass in an object and an alert value if it fail.

var ip= document.getElementById('ip');
if(isValidIPAddress(ip, "Invalid IP Address")){
//proceed...
}

US Social Security Number Validation

Testing US Social security number can be done with the below function.

function isValidSSN(elem, msg) {
	var value = elem.value.toLowerCase();
	var tmp = false;
    var re = /^([0-6]\d{2}|7[0-6]\d|77[0-2])([ \-]?)(\d{2})\2(\d{4})$/;
    if (!re.test(value)) { tmp = true; }
    var temp = value;
    if (value.indexOf("-") != -1) { temp = (value.split("-")).join(""); }
    if (value.indexOf(" ") != -1) { temp = (value.split(" ")).join(""); }
    if (temp.substring(0, 3) == "000") { tmp = true; }
    if (temp.substring(3, 5) == "00") { tmp = true; }
    if (temp.substring(5, 9) == "0000") { tmp = true; }

	if(tmp){
		alert(helperMsg);
		elem.focus();
		return false;
	}else
    return true;
}

In order to use this, we pass in an object and an alert value if it fail.

var ssn = document.getElementById('ssn');
if(isValidSSN(ssn, "Invalid US Social Security Number")){
//proceed...
}

US Zip Code Validation

We can valid US zip code using the following function.

function isValidZipCode(elem, msg) {
   var re = /^\d{5}([\-]\d{4})?$/;
   var value = elem.value.toLowerCase();
   if(re.test(value)){
		return true;
   }else {
		alert(helperMsg);
		elem.focus();
		return false;
   }
}

In order to use this, we pass in an object and an alert value if it fail.

var zip= document.getElementById('zip');
if(isValidSSN(zip, "Invalid US Zip Code")){
//proceed...
}

Date Validation

This function validate date with a given format.

function isValidDate(dateStr, format) {
   if (format == null) { format = "MDY"; }
   format = format.toUpperCase();
   if (format.length != 3) { format = "MDY"; }
   if ( (format.indexOf("M") == -1) || (format.indexOf("D") == -1) || _
      (format.indexOf("Y") == -1) ) { format = "MDY"; }
   if (format.substring(0, 1) == "Y") { // If the year is first
      var reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
      var reg2 = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
   } else if (format.substring(1, 2) == "Y") { // If the year is second
      var reg1 = /^\d{1,2}(\-|\/|\.)\d{2}\1\d{1,2}$/
      var reg2 = /^\d{1,2}(\-|\/|\.)\d{4}\1\d{1,2}$/
   } else { // The year must be third
      var reg1 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$/
      var reg2 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
   }
   // If it doesn't conform to the right format (with either a 2 digit year or 4 digit year), fail
   if ( (reg1.test(dateStr) == false) && (reg2.test(dateStr) == false) ) { return false; }
   var parts = dateStr.split(RegExp.$1); // Split into 3 parts based on what the divider was
   // Check to see if the 3 parts end up making a valid date
   if (format.substring(0, 1) == "M") { var mm = parts[0]; } else _
      if (format.substring(1, 2) == "M") { var mm = parts[1]; } else { var mm = parts[2]; }
   if (format.substring(0, 1) == "D") { var dd = parts[0]; } else _
      if (format.substring(1, 2) == "D") { var dd = parts[1]; } else { var dd = parts[2]; }
   if (format.substring(0, 1) == "Y") { var yy = parts[0]; } else _
      if (format.substring(1, 2) == "Y") { var yy = parts[1]; } else { var yy = parts[2]; }
   if (parseFloat(yy) <= 50) { yy = (parseFloat(yy) + 2000).toString(); }
   if (parseFloat(yy) <= 99) { yy = (parseFloat(yy) + 1900).toString(); }
   var dt = new Date(parseFloat(yy), parseFloat(mm)-1, parseFloat(dd), 0, 0, 0, 0);
   if (parseFloat(dd) != dt.getDate()) { return false; }
   if (parseFloat(mm)-1 != dt.getMonth()) { return false; }
   return true;
}

You will use the function this way,

if (!isValidDate(myDateString, "DMY")) { alert("The date is not in the correct format."); }

Time Validation

This function validate time such as

  1. 02:25AM
  2. 00:23PM
  3. 23:45PM
  4. 11:23
  5. etc.
function isValidTime(value) {
   var hasMeridian = false;
   var re = /^\d{1,2}[:]\d{2}([:]\d{2})?( [aApP][mM]?)?$/;
   if (!re.test(value)) { return false; }
   if (value.toLowerCase().indexOf("p") != -1) { hasMeridian = true; }
   if (value.toLowerCase().indexOf("a") != -1) { hasMeridian = true; }
   var values = value.split(":");
   if ( (parseFloat(values[0]) < 0) || (parseFloat(values[0]) > 23) ) { return false; }
   if (hasMeridian) {
      if ( (parseFloat(values[0]) < 1) || (parseFloat(values[0]) > 12) ) { return false; }
   }
   if ( (parseFloat(values[1]) < 0) || (parseFloat(values[1]) > 59) ) { return false; }
   if (values.length > 2) {
      if ( (parseFloat(values[2]) < 0) || (parseFloat(values[2]) > 59) ) { return false; }
   }
   return true;
}

Credit Card Validation

This function validate whether a given string format is similar to a credit card type.

function isValidCreditCard(type, ccnum) {
   if (type == "Visa") {
      // Visa: length 16, prefix 4, dashes optional.
      var re = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "MC") {
      // Mastercard: length 16, prefix 51-55, dashes optional.
      var re = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "Disc") {
      // Discover: length 16, prefix 6011, dashes optional.
      var re = /^6011-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "AmEx") {
      // American Express: length 15, prefix 34 or 37.
      var re = /^3[4,7]\d{13}$/;
   } else if (type == "Diners") {
      // Diners: length 14, prefix 30, 36, or 38.
      var re = /^3[0,6,8]\d{12}$/;
   }
   if (!re.test(ccnum)) return false;
   // Remove all dashes for the checksum checks to eliminate negative numbers
   ccnum = ccnum.split("-").join("");
   // Checksum ("Mod 10")
   // Add even digits in even length strings or odd digits in odd length strings.
   var checksum = 0;
   for (var i=(2-(ccnum.length % 2)); i<=ccnum.length; i+=2) {
      checksum += parseInt(ccnum.charAt(i-1));
   }
   // Analyze odd digits in even length strings or even digits in odd length strings.
   for (var i=(ccnum.length % 2) + 1; i<ccnum.length; i+=2) {
      var digit = parseInt(ccnum.charAt(i-1)) * 2;
      if (digit < 10) { checksum += digit; } else { checksum += (digit-9); }
   }
   if ((checksum % 10) == 0) return true; else return false;
}

Summary

Usually i will use these code in such a way to validate my form. I find it neat and tidy.

form.onsubmit = validation;
var validation = function(){
	var name = document.getElementById('ham_company');
	var email = document.getElementById('ham_email');
	var link = document.getElementById('ham_link');
	var description = document.getElementById('ham_desc');
	var banner = document.getElementById('ham_banner');
	var month = document.getElementById('ham_month');
	var url = document.getElementById('ham_url');
	var upload = document.getElementById('ham_upload');
	var quiz = document.getElementById('ham_quiz');
	if(isEmail(email, "Invalid Email Format"))
		if(isUrl(link, "Invalid link"))
			if(OneNotEmpty(url, upload, "Either image url or upload must be perform!"))
				if(isAllowedFileExtension(url, "Please provide an image with Gif, Png or Jpg extension Only"))
					if(isAllowedFileExtension(upload, "Please Upload Gif, Png or Jpg Images Files Only"))
						if(isSelected(month, "Please select a month"))
							if(isSelected(banner, "Please select a banner"))
								if(NotEmpty(quiz, "Please answer the quiz"))
									if(NotEmpty(name, "Please give us your name"))
									{
										return true;
									}

	return false;
}

On the other hand, you can always brings up new form validation snippets to share with me in this article. I will love to know 🙂

Inline, Internal or External CSS Style Print First?

It is a common thing for most web beginners to wonder which style will the browser print first when we declare multiple style. Although i have explain previous on the order priority of CSS, i forgotten about the importance of inline, internal and external CSS style that both designers and developers might wonder when they started on web.

Inline CSS

The inline CSS also refer as embedded style is usually mark as the highest priority over internal or external style. An inline style has the highest priority among others but the style can only be apply to an individual element. Here's an example

<div style='height:200px;width:200px;text-align:center;'>Click me!</div>

Inline style may be convenient to write but maintenance work will definitely kill you one day.

External CSS

The external CSS which the style is usually placed on an external file will usually have the lowest priority over these three type.

<link rel="stylesheet" type="text/css" href="http:/hungred.com/external.css">

Nonetheless, sometimes external CSS can have higher priority over the internal CSS in some circumstances.

Internal CSS

Internal CSS are definition declare inside of the HTML document with the style tag,

<style type='text/css'>
div{
height:200px;
width:200px;
text-align:center;
}
</style>

Internal CSS usually have the second highest priority among them. However, it will lose its priority if the external stylesheet declaration is placed at after the internal CSS. Hence,

<link rel="stylesheet" type="text/css" href="http:/hungred.com/external.css">
<style type='text/css'>
div{
height:200px;
width:200px;
text-align:center;
}
</style>

the internal CSS is after the external CSS. Therefore, the internal CSS has a higher priority. On the other hand,

<style type='text/css'>
div{
height:200px;
width:200px;
text-align:center;
}
</style>
<link rel="stylesheet" type="text/css" href="http:/hungred.com/external.css">

when the external CSS is after the internal CSS, the external CSS will have a higher priority.

Priority Sequences

Hence, we can produce a priority sequences of how CSS prioritize our CSS types.

  1. User Style
  2. Inline Style (inside HTML tag)
  3. Internal Style (usually on the HTML head section)
  4. External Style
  5. Browser Default Style

User style (the style that user define for your website) have the highest priority over all other types but as a developer or designer we should only worry about the priority given on inline, internal and external style. Nonetheless, it is also important to know that using !important will also mean that user style priority is overwrite by the HIGHEST priority (which is style declare with !important). That is also the reason why we should try to avoid the use of !important as a developer or designer to avoid any usability problem and utilize order priority in CSS.

Summary

Once we understand how order priority work in CSS, we can easily figure out how CSS cascade all our different styles into one. But one last thing to take note of. The order priority in this link only apply to internal and external style. Hence, if both internal and external have the same exact style definition which order priority in this link will CSS take as the highest priority. The answer lays in this article where we explain on the internal CSS section.