PHP Fastest way to get image width and height

Well, i am currently updating my WordPress plugin. I faced a problem in the past to retrieve image width to determine whether a particular image is require to resize. The problem here is that checking a particular image height and width is expensive job. In order to not impact the loading time of the site using my plugin, i forfeited the capability of resizing and resize the image regardless of the size. The plugin works fine since the resizing is doing it on the fly. However, problems arise when a smaller image is being resize and this is not a desirable result. Therefore, i would like to see whether there is a solution exist that can easily solve my problem.

Getting Image size using getImageSize()

Obviously, the task here is talking about PHP, we will look at the getImageSize() functionality exist within the naive php function. I personally was using this on the plugin to determine the size of the image. However, i immediately removed this after i notice the impact this functionality has caused on my site.

The reason? Remote image will need to be downloaded into your server and then it will be read locally by php. The pitfall here is the time used to download remotely to your server. If all your image is in your server and not somewhere else like in a CDN, this might not be a problem.

Better solutions

Well, the better solutions to get image quickly is to create your own script to retrieve the first few bytes of the file since the size of the image is located there. Credit goes to James @ zifiniti.com for the script below,

<?php
   function getimagesize($image_url){
    $handle = fopen ($image_url, "rb");
    $contents = ""; 
    if ($handle) {
    do {
        $count += 1;
        $data = fread($handle, 8192);
        if (strlen($data) == 0) {
            break;
       }   
    $contents .= $data;
    } while(true);
    } else { return false; }
    fclose ($handle);

    $im = ImageCreateFromString($contents);
    if (!$im) { return false; }
    $gis[0] = ImageSX($im);
    $gis[1] = ImageSY($im);
    // array member 3 is used below to keep with current getimagesize standards
    $gis[3] = "width={$gis[0]} height={$gis[1]}";
    ImageDestroy($im);
    return $gis;                                                                                                                                                       
   }   
}
?>

Assuming you have a large image file, this can really come in handle and reduce the time needed to load a site. But, its still slow! xD

List Of All Jobs in a select box

Today i was working on a registration and i needed a list of all job available for my user to choose. What will most of us do when this happen? Search Google! After that i left with despite because i fail to find such resource. The next terrifying thing most developer look at is the list of job available on Wikipedia (it just keep on going, damnit). Imagining compiling the whole few hundred list of job just to get them into a select box. Well, you don't have to imagine because i already did it. Hence, you get the joy while i do the work. lol~

<select class="select" id="selectbox" name="selectbox">
		<option value="Athlete">Athlete</option>
		<option value="Accountant">Accountant</option>
		<option value="Actor">Actor</option>
		<option value="Actress">Actress</option>
		<option value="Administrator">Administrator</option>
		<option value="Aerospace Engineer">Aerospace Engineer</option>
		<option value="Air Traffic Controller">Air Traffic Controller</option>
		<option value="Ambassador">Ambassador</option>
		<option value="Anesthetist">Anesthetist</option>
		<option value="Anchorman">Anchorman</option>
		<option value="Animator">Animator</option>
		<option value="Animal trainer">Animal trainer</option>
		<option value="Archaeologist">Archaeologist</option>
		<option value="Architect">Architect</option>
		<option value="Artist">Artist</option>
		<option value="Astronaut">Astronaut</option>
		<option value="Astronomer">Astronomer</option>
		<option value="Athletic trainer">Athletic trainer</option>
		<option value="Attorney">Attorney</option>
		<option value="Author">Author</option>
		<option value="Army">Army</option>
		<option value="Brain Surgeon">Brain Surgeon</option>
		<option value="Baker">Baker</option>
		<option value="Bank teller">Bank teller</option>
		<option value="Banker">Banker</option>
		<option value="Barber">Barber</option>
		<option value="Barista">Barista</option>
		<option value="Barrister">Barrister</option>
		<option value="Bartender">Bartender</option>
		<option value="Babysitter">Babysitter</option>
		<option value="Beauty queen">Beauty queen</option>
		<option value="Beauty therapist">Beauty therapist</option>
		<option value="Beekeeper">Beekeeper</option>
		<option value="Blacksmith">Blacksmith</option>
		<option value="Boilermaker">Boilermaker</option>
		<option value="Bookkeeper">Bookkeeper</option>
		<option value="Bookseller">Bookseller</option>
		<option value="Brewer">Brewer</option>
		<option value="Butcher">Butcher</option>
		<option value="Butler">Butler</option>
		<option value="Builder">Builder</option>
		<option value="Cab driver">Cab driver</option>
		<option value="Calligrapher">Calligrapher</option>
		<option value="Cameraman">Cameraman</option>
		<option value="Car designer">Car designer</option>
		<option value="Cardiologist">Cardiologist</option>
		<option value="Carpenter">Carpenter</option>
		<option value="Cartoonist">Cartoonist</option>
		<option value="Cartographer">Cartographer</option>
		<option value="Cashier">Cashier</option>
		<option value="Cellist">Cellist</option>
		<option value="Chess player">Chess player</option>
		<option value="CIO (Chief Information Officer)">CIO (Chief Information Officer)</option>
		<option value="CEO (Chief Executive Officer)">CEO (Chief Executive Officer)</option>
		<option value="CTO (Chief Technology Officer)">CTO (Chief Technology Officer)</option>
		<option value="CFO (Chief Financial Officer)">CFO (Chief Financial Officer)</option>
		<option value="Chauffeur">Chauffeur</option>
		<option value="Cheesemaker">Cheesemaker</option>
		<option value="Cook)">Cook)</option>
		<option value="Chemist">Chemist</option>
		<option value="Chief of police">Chief of police</option>
		<option value="Chimney sweep">Chimney sweep</option>
		<option value="Civil servant">Civil servant</option>
		<option value="Civil engineer">Civil engineer</option>
		<option value="Clarinetist">Clarinetist</option>
		<option value="Cleaner">Cleaner</option>
		<option value="Clerk">Clerk</option>
		<option value="Clockmaker">Clockmaker</option>
		<option value="Coach">Coach</option>
		<option value="Coachman">Coachman</option>
		<option value="Coast guard">Coast guard</option>
		<option value="Cobbler">Cobbler</option>
		<option value="Columnist">Columnist</option>
		<option value="Comedian">Comedian</option>
		<option value="Company Secretary">Company Secretary</option>
		<option value="Compasssmith">Compasssmith</option>
		<option value="Composer">Composer</option>
		<option value="Computer programmer">Computer programmer</option>
		<option value="Conductor (music)">Conductor (music)</option>
		<option value="Construction engineer">Construction engineer</option>
		<option value="Construction worker">Construction worker</option>
		<option value="Consul">Consul</option>
		<option value="Consultant">Consultant</option>
		<option value="Contractor, general">Contractor, general</option>
		<option value="Coroner">Coroner</option>
		<option value="Corrector">Corrector</option>
		<option value="Cosmonaut">Cosmonaut</option>
		<option value="Costume Designer">Costume Designer</option>
		<option value="Courier">Courier</option>
		<option value="Cryptographer">Cryptographer</option>
		<option value="Currier">Currier</option>
		<option value="Customs officer">Customs officer</option>
		<option value="Dancer">Dancer</option>
		<option value="Dentist">Dentist</option>
		<option value="Deputy (law enforcement)">Deputy (law enforcement)</option>
		<option value="Dermatologist">Dermatologist</option>
		<option value="Designer/Developer">Designer/Developer</option>
		<option value="Detective">Detective</option>
		<option value="Dictator">Dictator</option>
		<option value="Disc jockey">Disc jockey</option>
		<option value="Diver">Diver</option>
		<option value="Doctor">Doctor</option>
		<option value="Dog walker">Dog walker</option>
		<option value="Doorman">Doorman</option>
		<option value="Dressmaker">Dressmaker</option>
		<option value="Ecologist">Ecologist</option>
		<option value="Economist">Economist</option>
		<option value="Editor">Editor</option>
		<option value="Electrical engineer">Electrical engineer</option>
		<option value="Electrician">Electrician</option>
		<option value="Elevator mechanic">Elevator mechanic</option>
		<option value="Engineer">Engineer</option>
		<option value="Engraver">Engraver</option>
		<option value="Entrepreneur">Entrepreneur</option>
		<option value="Environmental scientist">Environmental scientist</option>
		<option value="Executive manager">Executive manager</option>
		<option value="Exterminator">Exterminator</option>
		<option value="Falconer">Falconer</option>
		<option value="Farmer">Farmer</option>
		<option value="Farrier">Farrier</option>
		<option value="Fashion designer">Fashion designer</option>
		<option value="FBI Agent">FBI Agent</option>
		<option value="Film director">Film director</option>
		<option value="Film producer">Film producer</option>
		<option value="Financial adviser">Financial adviser</option>
		<option value="Fire marshal">Fire marshal</option>
		<option value="Fire Safety Officer">Fire Safety Officer</option>
		<option value="Firefighter">Firefighter</option>
		<option value="First Mate">First Mate</option>
		<option value="Fishmonger">Fishmonger</option>
		<option value="Fisherman">Fisherman</option>
		<option value="Fitter">Fitter</option>
		<option value="Flavorist">Flavorist</option>
		<option value="Fletcher">Fletcher</option>
		<option value="Flight attendant">Flight attendant</option>
		<option value="Flight instructor">Flight instructor</option>
		<option value="Florist">Florist</option>
		<option value="Flutist">Flutist</option>
		<option value="Food critic">Food critic</option>
		<option value="Footballer">Footballer</option>
		<option value="Forester">Forester</option>
		<option value="Fortune teller">Fortune teller</option>
		<option value="Funeral Director">Funeral Director</option>
		<option value="Gamekeeper">Gamekeeper</option>
		<option value="Game designer">Game designer</option>
		<option value="Gardener">Gardener</option>
		<option value="Gemcutter">Gemcutter</option>
		<option value="Genealogist">Genealogist</option>
		<option value="General">General</option>
		<option value="Geologist">Geologist</option>
		<option value="Goldsmith">Goldsmith</option>
		<option value="Government agent">Government agent</option>
		<option value="Governor">Governor</option>
		<option value="Graphic Designer">Graphic Designer</option>
		<option value="Gravedigger">Gravedigger</option>
		<option value="Greengrocer">Greengrocer</option>
		<option value="Grocer">Grocer</option>
		<option value="Guide">Guide</option>
		<option value="Guitarist">Guitarist</option>
		<option value="Gunsmith">Gunsmith</option>
		<option value="Harpist">Harpist</option>
		<option value="Handyman">Handyman</option>
		<option value="Hairdresser">Hairdresser</option>
		<option value="Harbourmaster">Harbourmaster</option>
		<option value="Harper">Harper</option>
		<option value="Hatter">Hatter</option>
		<option value="Historian">Historian</option>
		<option value="Homeopath">Homeopath</option>
		<option value="Hotel manager">Hotel manager</option>
		<option value="Housekeeper">Housekeeper</option>
		<option value="Hairstylist">Hairstylist</option>
		<option value="Human Resource Manager">Human Resource Manager</option>
		<option value="Human Resource Assistant">Human Resource Assistant</option>
		<option value="Illuminator">Illuminator</option>
		<option value="Illusionist">Illusionist</option>
		<option value="Illustrator">Illustrator</option>
		<option value="Importer">Importer</option>
		<option value="Industrial engineer">Industrial engineer</option>
		<option value="Industrialist">Industrialist</option>
		<option value="Information Technologist">Information Technologist</option>
		<option value="Information Designer">Information Designer</option>
		<option value="Inker">Inker</option>
		<option value="Innkeeper">Innkeeper</option>
		<option value="Instructor">Instructor</option>
		<option value="Interior designer">Interior designer</option>
		<option value="Interpreter">Interpreter</option>
		<option value="Interrogator">Interrogator</option>
		<option value="Inventor">Inventor</option>
		<option value="disambiguation needed">disambiguation needed</option>
		<option value="Investment banker">Investment banker</option>
		<option value="Investment broker">Investment broker</option>
		<option value="Ironmonger">Ironmonger</option>
		<option value="Ironmaster">Ironmaster</option>
		<option value="Ironworker">Ironworker</option>
		<option value="Jailer">Jailer</option>
		<option value="Janitor">Janitor</option>
		<option value="Jeweller">Jeweller</option>
		<option value="Journalist">Journalist</option>
		<option value="Jurist">Jurist</option>
		<option value="Judge">Judge</option>
		<option value="Jockey">Jockey</option>
		<option value="Joggler">Joggler</option>
		<option value="Karate master">Karate master</option>
		<option value="Kinesiologist">Kinesiologist</option>
		<option value="Laborer">Laborer</option>
		<option value="Landlady)">Landlady)</option>
		<option value="Lavendar)">Lavendar)</option>
		<option value="Law enforcement agent">Law enforcement agent</option>
		<option value="Lawyer">Lawyer</option>
		<option value="Leadworker">Leadworker</option>
		<option value="Leatherer">Leatherer</option>
		<option value="Leather worker">Leather worker</option>
		<option value="Lecturer">Lecturer</option>
		<option value="Level designer (also Mapper)">Level designer (also Mapper)</option>
		<option value="Librarianship">Librarianship</option>
		<option value="Librettist">Librettist</option>
		<option value="Lifeguard">Lifeguard</option>
		<option value="Lighthouse keeper">Lighthouse keeper</option>
		<option value="Lighting technician">Lighting technician</option>
		<option value="Lineman">Lineman</option>
		<option value="Linguist">Linguist</option>
		<option value="Loan officer">Loan officer</option>
		<option value="Lobbyist">Lobbyist</option>
		<option value="Locksmith">Locksmith</option>
		<option value="Lumberjack">Lumberjack</option>
		<option value="Lyricist">Lyricist</option>
		<option value="Magistrate">Magistrate</option>
		<option value="Magnate">Magnate</option>
		<option value="Maid">Maid</option>
		<option value="Mailman or Mail carrier">Mailman or Mail carrier</option>
		<option value="Make-up artist">Make-up artist</option>
		<option value="Management consultant">Management consultant</option>
		<option value="Manager">Manager</option>
		<option value="Manicurist">Manicurist</option>
		<option value="Manufacturer">Manufacturer</option>
		<option value="Marine">Marine</option>
		<option value="Marine biologist">Marine biologist</option>
		<option value="Market gardener">Market gardener</option>
		<option value="Martial artist">Martial artist</option>
		<option value="Mason">Mason</option>
		<option value="Master of business administration">Master of business administration</option>
		<option value="MC)">MC)</option>
		<option value="masseur)">masseur)</option>
		<option value="Matador">Matador</option>
		<option value="Mathematician">Mathematician</option>
		<option value="Mechanic">Mechanic</option>
		<option value="Mechanical Engineer">Mechanical Engineer</option>
		<option value="Mechanician">Mechanician</option>
		<option value="Mediator">Mediator</option>
		<option value="Medic">Medic</option>
		<option value="Medical biller">Medical biller</option>
		<option value="Medical Transcriptionist">Medical Transcriptionist</option>
		<option value="Mesmerist">Mesmerist</option>
		<option value="Messenger">Messenger</option>
		<option value="Mid-wife">Mid-wife</option>
		<option value="Milkmaid)">Milkmaid)</option>
		<option value="Miller">Miller</option>
		<option value="Miner">Miner</option>
		<option value="Missionary">Missionary</option>
		<option value="Model">Model</option>
		<option value="Modeller">Modeller</option>
		<option value="Moneychanger">Moneychanger</option>
		<option value="Moneylender">Moneylender</option>
		<option value="Monk">Monk</option>
		<option value="Mortgage broker">Mortgage broker</option>
		<option value="Mountaineer">Mountaineer</option>
		<option value="Muralist">Muralist</option>
		<option value="Musician">Musician</option>
		<option value="Navigator">Navigator</option>
		<option value="N??gociant">N??gociant</option>
		<option value="Negotiator">Negotiator</option>
		<option value="Netmaker">Netmaker</option>
		<option value="Neurologist">Neurologist</option>
		<option value="Newscaster">Newscaster</option>
		<option value="Night auditor">Night auditor</option>
		<option value="Nightwatchmen">Nightwatchmen</option>
		<option value="Notary">Notary</option>
		<option value="Novelist">Novelist</option>
		<option value="Numerologist">Numerologist</option>
		<option value="Numismatist">Numismatist</option>
		<option value="Nun">Nun</option>
		<option value="Nursemaid">Nursemaid</option>
		<option value="Nurse">Nurse</option>
		<option value="Nutritionist">Nutritionist</option>
		<option value="Oboist">Oboist</option>
		<option value="Obstetrician">Obstetrician</option>
		<option value="Occupational therapist">Occupational therapist</option>
		<option value="Odontologist">Odontologist</option>
		<option value="Oncologist">Oncologist</option>
		<option value="Ontologist">Ontologist</option>
		<option value="Operator">Operator</option>
		<option value="Ophthalmologist">Ophthalmologist</option>
		<option value="Optometrist)">Optometrist)</option>
		<option value="Oracle">Oracle</option>
		<option value="Ordinary Seaman">Ordinary Seaman</option>
		<option value="disambiguation needed">disambiguation needed</option>
		<option value="Orthodontist">Orthodontist</option>
		<option value="Ornithologist">Ornithologist</option>
		<option value="Ostler">Ostler</option>
		<option value="Otorhinolaryngologist">Otorhinolaryngologist</option>
		<option value="Optometrist">Optometrist</option>
		<option value="Ocularist">Ocularist</option>
		<option value="Opthamologist">Opthamologist</option>
		<option value="Painter">Painter</option>
		<option value="Paleontologist">Paleontologist</option>
		<option value="Paralegal">Paralegal</option>
		<option value="Paramedic">Paramedic</option>
		<option value="Park ranger">Park ranger</option>
		<option value="Parole Officer">Parole Officer</option>
		<option value="Pastor">Pastor</option>
		<option value="Patent attorney">Patent attorney</option>
		<option value="Patent examiner">Patent examiner</option>
		<option value="Pathologist">Pathologist</option>
		<option value="Pawnbroker">Pawnbroker</option>
		<option value="Peddler">Peddler</option>
		<option value="Pediatrician">Pediatrician</option>
		<option value="Pedologist (soil)">Pedologist (soil)</option>
		<option value="Percussionist">Percussionist</option>
		<option value="Perfumer">Perfumer</option>
		<option value="Personal Trainer">Personal Trainer</option>
		<option value="Pharmacist">Pharmacist</option>
		<option value="Philanthropist">Philanthropist</option>
		<option value="Philologist">Philologist</option>
		<option value="Philosopher">Philosopher</option>
		<option value="Photographer">Photographer</option>
		<option value="Photo Specialist">Photo Specialist</option>
		<option value="Physical Therapist">Physical Therapist</option>
		<option value="Physician">Physician</option>
		<option value="Physician Assistant">Physician Assistant</option>
		<option value="Physicist">Physicist</option>
		<option value="Physiognomist">Physiognomist</option>
		<option value="Physiotherapist">Physiotherapist</option>
		<option value="Pianist">Pianist</option>
		<option value="Piano tuner">Piano tuner</option>
		<option value="Pilot (shipping)">Pilot (shipping)</option>
		<option value="Pilot (aviation)">Pilot (aviation)</option>
		<option value="Pirate">Pirate</option>
		<option value="Plumber">Plumber</option>
		<option value="Podiatrist">Podiatrist</option>
		<option value="Poet">Poet</option>
		<option value="Police inspector">Police inspector</option>
		<option value="Politician">Politician</option>
		<option value="disambiguation needed">disambiguation needed</option>
		<option value="Presenter">Presenter</option>
		<option value="President">President</option>
		<option value="Press officer">Press officer</option>
		<option value="Priest">Priest</option>
		<option value="Princess">Princess</option>
		<option value="Principal">Principal</option>
		<option value="Printer">Printer</option>
		<option value="Private detective">Private detective</option>
		<option value="Probation Officer">Probation Officer</option>
		<option value="Proctologist">Proctologist</option>
		<option value="Product designer">Product designer</option>
		<option value="Professor">Professor</option>
		<option value="Professional dominant">Professional dominant</option>
		<option value="Programmer">Programmer</option>
		<option value="Project Manager">Project Manager</option>
		<option value="Proofreader">Proofreader</option>
		<option value="Psychiatrist">Psychiatrist</option>
		<option value="Psychodramatist">Psychodramatist</option>
		<option value="Psychologist">Psychologist</option>
		<option value="Public Relations Officer">Public Relations Officer</option>
		<option value="Public speaker">Public speaker</option>
		<option value="Publisher">Publisher</option>
		<option value="Porn star">Porn star</option>
		<option value="Queen consort">Queen consort</option>
		<option value="Queen regnant">Queen regnant</option>
		<option value="Quilter">Quilter</option>
		<option value="Radiologist">Radiologist</option>
		<option value="Radiographer">Radiographer</option>
		<option value="Real estate broker">Real estate broker</option>
		<option value="Real estate investor">Real estate investor</option>
		<option value="Real estate developer">Real estate developer</option>
		<option value="Receptionist">Receptionist</option>
		<option value="Record Producer">Record Producer</option>
		<option value="Referee">Referee</option>
		<option value="Refuse collector">Refuse collector</option>
		<option value="Registrar">Registrar</option>
		<option value="Reporter">Reporter</option>
		<option value="Researcher">Researcher</option>
		<option value="Respiratory Therapist">Respiratory Therapist</option>
		<option value="Restaurateur">Restaurateur</option>
		<option value="Retailer">Retailer</option>
		<option value="Rubbish Collector">Rubbish Collector</option>
		<option value="Sailmaker">Sailmaker</option>
		<option value="Sailor">Sailor</option>
		<option value="Salesmen">Salesmen</option>
		<option value="Sanitation worker">Sanitation worker</option>
		<option value="Saucier">Saucier</option>
		<option value="Saxophonist">Saxophonist</option>
		<option value="disambiguation needed">disambiguation needed</option>
		<option value="Scientist">Scientist</option>
		<option value="School superintendent">School superintendent</option>
		<option value="Scout">Scout</option>
		<option value="Screenwriter">Screenwriter</option>
		<option value="Scrivener)">Scrivener)</option>
		<option value="Seamstress">Seamstress</option>
		<option value="Second Mate">Second Mate</option>
		<option value="Secret service agent">Secret service agent</option>
		<option value="Secretary general">Secretary general</option>
		<option value="Security guard">Security guard</option>
		<option value="Senator">Senator</option>
		<option value="SEO (search engine optimizer)">SEO (search engine optimizer)</option>
		<option value="Sexton">Sexton</option>
		<option value="Sheepshearer">Sheepshearer</option>
		<option value="Sheriff">Sheriff</option>
		<option value="Sheriff officer">Sheriff officer</option>
		<option value="Shoemaker">Shoemaker</option>
		<option value="Shop assistant">Shop assistant</option>
		<option value="Singer">Singer</option>
		<option value="Skydiver">Skydiver</option>
		<option value="Sleeper">Sleeper</option>
		<option value="Sleuth">Sleuth</option>
		<option value="Social worker">Social worker</option>
		<option value="Socialite">Socialite</option>
		<option value="Software engineer">Software engineer</option>
		<option value="Soil scientist">Soil scientist</option>
		<option value="Soldier">Soldier</option>
		<option value="Solicitor">Solicitor</option>
		<option value="Sommelier">Sommelier</option>
		<option value="Sonographer">Sonographer</option>
		<option value="Sound Engineer">Sound Engineer</option>
		<option value="Special agent">Special agent</option>
		<option value="Speech therapist">Speech therapist</option>
		<option value="Sportsman">Sportsman</option>
		<option value="Spy">Spy</option>
		<option value="Statistician">Statistician</option>
		<option value="Street artist">Street artist</option>
		<option value="Street musician">Street musician</option>
		<option value="Stevedore">Stevedore</option>
		<option value="Street sweeper">Street sweeper</option>
		<option value="Street vendor">Street vendor</option>
		<option value="Structural engineers">Structural engineers</option>
		<option value="Stunt double">Stunt double</option>
		<option value="Stunt performer">Stunt performer</option>
		<option value="Surgeon">Surgeon</option>
		<option value="Supervisor">Supervisor</option>
		<option value="Surveyor">Surveyor</option>
		<option value="Swimmer">Swimmer</option>
		<option value="Switchboard operator">Switchboard operator</option>
		<option value="System administrator">System administrator</option>
		<option value="Systems analyst">Systems analyst</option>
		<option value="Student">Student</option>
		<option value="Tailor">Tailor</option>
		<option value="Tanner">Tanner</option>
		<option value="Tapester)">Tapester)</option>
		<option value="Tax Collector">Tax Collector</option>
		<option value="Tax Lawyer">Tax Lawyer</option>
		<option value="Taxidermist">Taxidermist</option>
		<option value="Taxicab driver">Taxicab driver</option>
		<option value="Taxonomist">Taxonomist</option>
		<option value="Tea lady">Tea lady</option>
		<option value="Teacher">Teacher</option>
		<option value="Technician">Technician</option>
		<option value="Technologist">Technologist</option>
		<option value="Technical Writer">Technical Writer</option>
		<option value="Telegraph operator)">Telegraph operator)</option>
		<option value="Telephone operator">Telephone operator</option>
		<option value="Tennis player">Tennis player</option>
		<option value="Test developer">Test developer</option>
		<option value="Test pilot">Test pilot</option>
		<option value="Torchwood Officer">Torchwood Officer</option>
		<option value="Thatcher">Thatcher</option>
		<option value="Theatre director">Theatre director</option>
		<option value="Therapist">Therapist</option>
		<option value="Thimbler">Thimbler</option>
		<option value="Tiler">Tiler</option>
		<option value="Toolmaker">Toolmaker</option>
		<option value="Trademark attorney">Trademark attorney</option>
		<option value="Trader">Trader</option>
		<option value="Tradesman">Tradesman</option>
		<option value="Trainer (business)">Trainer (business)</option>
		<option value="Transit planner">Transit planner</option>
		<option value="Translator">Translator</option>
		<option value="Treasurer">Treasurer</option>
		<option value="Truck Driver">Truck Driver</option>
		<option value="Turner">Turner</option>
		<option value="Tutor">Tutor</option>
		<option value="Tyler">Tyler</option>
		<option value="Typist">Typist</option>
		<option value="Undertaker">Undertaker</option>
		<option value="Ufologist">Ufologist</option>
		<option value="Undercover agent">Undercover agent</option>
		<option value="Underwriter">Underwriter</option>
		<option value="Upholsterer">Upholsterer</option>
		<option value="Urologist">Urologist</option>
		<option value="Usher">Usher</option>
		<option value="Underwear model">Underwear model</option>
		<option value="Valet">Valet</option>
		<option value="Verger">Verger</option>
		<option value="Veterinarian">Veterinarian</option>
		<option value="Vibraphonist">Vibraphonist</option>
		<option value="Vicar">Vicar</option>
		<option value="Video editor">Video editor</option>
		<option value="Video game developer">Video game developer</option>
		<option value="Vintner">Vintner</option>
		<option value="Violinist">Violinist</option>
		<option value="Violist">Violist</option>
		<option value="Voice Actor">Voice Actor</option>
		<option value="Waitress)">Waitress)</option>
		<option value="disambiguation needed">disambiguation needed</option>
		<option value="Watchmaker">Watchmaker</option>
		<option value="Weaponsmith">Weaponsmith</option>
		<option value="Weatherman">Weatherman</option>
		<option value="Weaver">Weaver</option>
		<option value="Web designer">Web designer</option>
		<option value="Web developer">Web developer</option>
		<option value="Wedding Planner">Wedding Planner</option>
		<option value="Welder">Welder</option>
		<option value="Wet nurse">Wet nurse</option>
		<option value="Woodcarver">Woodcarver</option>
		<option value="Wood cutter">Wood cutter</option>
		<option value="Wrangler">Wrangler</option>
		<option value="Winemaker">Winemaker</option>
		<option value="Writer">Writer</option>
		<option value="Xylophonist">Xylophonist</option>
		<option value="Yodeler">Yodeler</option>
		<option value="Zookeeper">Zookeeper</option>
		<option value="Zoologist">Zoologist</option>
	</select>

Enjoy 🙂

Update:

I notice the above is pretty hard to find which has been previously selected by the user. Hence, i place them into an array and put it up here hopefully someone will find it useful for a list of all jobs in a php array 🙂

<select class="select" id="user_job" name="user_job">
		<option value=""> - Job - </option>
		<?php
			$loop = array('Athlete',		'Accountant',		'Actor',		'Actress',		'Administrator',		'Aerospace Engineer',		'Air Traffic Controller',		'Ambassador',		'Anesthetist',		'Anchorman',		'Animator',		'Animal trainer',		'Archaeologist',		'Architect',		'Artist',		'Astronaut',		'Astronomer',		'Athletic trainer',		'Attorney',		'Author',		'Army',		'Brain Surgeon',		'Baker',		'Bank teller',		'Banker',		'Barber',		'Barista',		'Barrister',		'Bartender',		'Babysitter',		'Beauty queen',		'Beauty therapist',		'Beekeeper',		'Blacksmith',		'Boilermaker',		'Bookkeeper',		'Bookseller',		'Brewer',		'Butcher',		'Butler',		'Builder',		'Cab driver',		'Calligrapher',		'Cameraman',		'Car designer',		'Cardiologist',		'Carpenter',		'Cartoonist',		'Cartographer',		'Cashier',		'Cellist',		'Chess player',		'CIO (Chief Information Officer)',		'CEO (Chief Executive Officer)',		'CTO (Chief Technology Officer)',		'CFO (Chief Financial Officer)',		'Chauffeur',		'Cheesemaker',		'Cook)',		'Chemist',		'Chief of police',		'Chimney sweep',		'Civil servant',		'Civil engineer',		'Clarinetist',		'Cleaner',		'Clerk',		'Clockmaker',		'Coach',		'Coachman',		'Coast guard',		'Cobbler',		'Columnist',		'Comedian',		'Company Secretary',		'Compasssmith',		'Composer',		'Computer programmer',		'Conductor (music)',		'Construction engineer',		'Construction worker',		'Consul',		'Consultant',		'Contractor, general',		'Coroner',		'Corrector',		'Cosmonaut',		'Costume Designer',		'Courier',		'Cryptographer',		'Currier',		'Customs officer',		'Dancer',		'Dentist',		'Deputy (law enforcement)',		'Dermatologist',		'Designer/Developer',		'Detective',		'Dictator',		'Disc jockey',		'Diver',		'Doctor',		'Dog walker',		'Doorman',		'Dressmaker',		'Ecologist',		'Economist',		'Editor',		'Electrical engineer',		'Electrician',		'Elevator mechanic',		'Engineer',		'Engraver',		'Entrepreneur',		'Environmental scientist',		'Executive manager',		'Exterminator',		'Falconer',		'Farmer',		'Farrier',		'Fashion designer',		'FBI Agent',		'Film director',		'Film producer',		'Financial adviser',		'Fire marshal',		'Fire Safety Officer',		'Firefighter',		'First Mate',		'Fishmonger',		'Fisherman',		'Fitter',		'Flavorist',		'Fletcher',		'Flight attendant',		'Flight instructor',		'Florist',		'Flutist',		'Food critic',		'Footballer',		'Forester',		'Fortune teller',		'Funeral Director',		'Gamekeeper',		'Game designer',		'Gardener',		'Gemcutter',		'Genealogist',		'General',		'Geologist',		'Goldsmith',		'Government agent',		'Governor',		'Graphic Designer',		'Gravedigger',		'Greengrocer',		'Grocer',		'Guide',		'Guitarist',		'Gunsmith',		'Harpist',		'Handyman',		'Hairdresser',		'Harbourmaster',		'Harper',		'Hatter',		'Historian',		'Homeopath',		'Hotel manager',		'Housekeeper',		'Hairstylist',		'Human Resource Manager',		'Human Resource Assistant',		'Illuminator',		'Illusionist',		'Illustrator',		'Importer',		'Industrial engineer',		'Industrialist',		'Information Technologist',		'Information Designer',		'Inker',		'Innkeeper',		'Instructor',		'Interior designer',		'Interpreter',		'Interrogator',		'Inventor',		'disambiguation needed',		'Investment banker',		'Investment broker',		'Ironmonger',		'Ironmaster',		'Ironworker',		'Jailer',		'Janitor',		'Jeweller',		'Journalist',		'Jurist',		'Judge',		'Jockey',		'Joggler',		'Karate master',		'Kinesiologist',		'Laborer',		'Landlady)',		'Lavendar)',		'Law enforcement agent',		'Lawyer',		'Leadworker',		'Leatherer',		'Leather worker',		'Lecturer',		'Level designer (also Mapper)',		'Librarianship',		'Librettist',		'Lifeguard',		'Lighthouse keeper',		'Lighting technician',		'Lineman',		'Linguist',		'Loan officer',		'Lobbyist',		'Locksmith',		'Lumberjack',		'Lyricist',		'Magistrate',		'Magnate',		'Maid',		'Mailman or Mail carrier',		'Make-up artist',		'Management consultant',		'Manager',		'Manicurist',		'Manufacturer',		'Marine',		'Marine biologist',		'Market gardener',		'Martial artist',		'Mason',		'Master of business administration',		'MC)',		'masseur)',		'Matador',		'Mathematician',		'Mechanic',		'Mechanical Engineer',		'Mechanician',		'Mediator',		'Medic',		'Medical biller',		'Medical Transcriptionist',		'Mesmerist',		'Messenger',		'Mid-wife',		'Milkmaid)',		'Miller',		'Miner',		'Missionary',		'Model',		'Modeller',		'Moneychanger',		'Moneylender',		'Monk',		'Mortgage broker',		'Mountaineer',		'Muralist',		'Musician',		'Navigator',		'N??gociant',		'Negotiator',		'Netmaker',		'Neurologist',		'Newscaster',		'Night auditor',		'Nightwatchmen',		'Notary',		'Novelist',		'Numerologist',		'Numismatist',		'Nun',		'Nursemaid',		'Nurse',		'Nutritionist',		'Oboist',		'Obstetrician',		'Occupational therapist',		'Odontologist',		'Oncologist',		'Ontologist',		'Operator',		'Ophthalmologist',		'Optometrist)',		'Oracle',		'Ordinary Seaman',		'disambiguation needed',		'Orthodontist',		'Ornithologist',		'Ostler',		'Otorhinolaryngologist',		'Optometrist',		'Ocularist',		'Opthamologist',		'Painter',		'Paleontologist',		'Paralegal',		'Paramedic',		'Park ranger',		'Parole Officer',		'Pastor',		'Patent attorney',		'Patent examiner',		'Pathologist',		'Pawnbroker',		'Peddler',		'Pediatrician',		'Pedologist (soil)',		'Percussionist',		'Perfumer',		'Personal Trainer',		'Pharmacist',		'Philanthropist',		'Philologist',		'Philosopher',		'Photographer',		'Photo Specialist',		'Physical Therapist',		'Physician',		'Physician Assistant',		'Physicist',		'Physiognomist',		'Physiotherapist',		'Pianist',		'Piano tuner',		'Pilot (shipping)',		'Pilot (aviation)',		'Pirate',		'Plumber',		'Podiatrist',		'Poet',		'Police inspector',		'Politician',		'disambiguation needed',		'Presenter',		'President',		'Press officer',		'Priest',		'Princess',		'Principal',		'Printer',		'Private detective',		'Probation Officer',		'Proctologist',		'Product designer',		'Professor',		'Professional dominant',		'Programmer',		'Project Manager',		'Proofreader',		'Psychiatrist',		'Psychodramatist',		'Psychologist',		'Public Relations Officer',		'Public speaker',		'Publisher',		'Porn star',		'Queen consort',		'Queen regnant',		'Quilter',		'Radiologist',		'Radiographer',		'Real estate broker',		'Real estate investor',		'Real estate developer',		'Receptionist',		'Record Producer',		'Referee',		'Refuse collector',		'Registrar',		'Reporter',		'Researcher',		'Respiratory Therapist',		'Restaurateur',		'Retailer',		'Rubbish Collector',		'Sailmaker',		'Sailor',		'Salesmen',		'Sanitation worker',		'Saucier',		'Saxophonist',		'disambiguation needed',		'Scientist',		'School superintendent',		'Scout',		'Screenwriter',		'Scrivener)',		'Seamstress',		'Second Mate',		'Secret service agent',		'Secretary general',		'Security guard',		'Senator',		'SEO (search engine optimizer)',		'Sexton',		'Sheepshearer',		'Sheriff',		'Sheriff officer',		'Shoemaker',		'Shop assistant',		'Singer',		'Skydiver',		'Sleeper',		'Sleuth',		'Social worker',		'Socialite',		'Software engineer',		'Soil scientist',		'Soldier',		'Solicitor',		'Sommelier',		'Sonographer',		'Sound Engineer',		'Special agent',		'Speech therapist',		'Sportsman',		'Spy',		'Statistician',		'Street artist',		'Street musician',		'Stevedore',		'Street sweeper',		'Street vendor',		'Structural engineers',		'Stunt double',		'Stunt performer',		'Surgeon',		'Supervisor',		'Surveyor',		'Swimmer',		'Switchboard operator',		'System administrator',		'Systems analyst',		'Student',		'Tailor',		'Tanner',		'Tapester)',		'Tax Collector',		'Tax Lawyer',		'Taxidermist',		'Taxicab driver',		'Taxonomist',		'Tea lady',		'Teacher',		'Technician',		'Technologist',		'Technical Writer',		'Telegraph operator)',		'Telephone operator',		'Tennis player',		'Test developer',		'Test pilot',		'Torchwood Officer',		'Thatcher',		'Theatre director',		'Therapist',		'Thimbler',		'Tiler',		'Toolmaker',		'Trademark attorney',		'Trader',		'Tradesman',		'Trainer (business)',		'Transit planner',		'Translator',		'Treasurer',		'Truck Driver',		'Turner',		'Tutor',		'Tyler',		'Typist',		'Undertaker',		'Ufologist',		'Undercover agent',		'Underwriter',		'Upholsterer',		'Urologist',		'Usher',		'Underwear model',		'Valet',		'Verger',		'Veterinarian',		'Vibraphonist',		'Vicar',		'Video editor',		'Video game developer',		'Vintner',		'Violinist',		'Violist',		'Voice Actor',		'Waitress)',		'disambiguation needed',		'Watchmaker',		'Weaponsmith',		'Weatherman',		'Weaver',		'Web designer',		'Web developer',		'Wedding Planner',		'Welder',		'Wet nurse',		'Woodcarver',		'Wood cutter',		'Wrangler',		'Winemaker',		'Writer',		'Xylophonist',		'Yodeler',		'Zookeeper',		'Zoologist');
			foreach($loop as $value){
				if($_POST['user_job'] == $value )
				echo '<option value="'.$value.'" selected>'.$value.'</option>';
				else
				echo '<option value="'.$value.'">'.$value.'</option>';
			}
		?>
	</select>

200++ Photoshop Photo Effects

Have you ever wonder where is that photo effect tutorial you saw the other day and start searching all over the internet but couldn't find what you saw initially? Honestly, i have. That is why i throw them all into this article instead. But i also use these article to gain inspiration on what to do with my photo image. Sometimes we are like a lost bird when it comes to creative design. Hence, putting up links of images can really benefit myself and hopefully people who come across this article too.

Create a Powerful Mental Wave Explosion Effect

wave-explosion

Photo to Pencil Sketch Effect

pencil

Sin City Style Effect

sincity

How To Make Your Own Vector Portraits

vector

Tutorial: Good and Evil Photo Effect

evil

The Making of Mystic Effect

mystic

Transform A Person Into An Alien Effect

alien-photoshop

Reflective Bubbles Effect

3315027133_4f9e8c8241

Crack and Peel Effect

3315027243_4fcabe071f

Expressive Lighting Effect

aura-effect

Displacement Effect

awesome-effect

Vector Composite Effect from a Photo

blabus

Easy Watercolor Painting Effect

cartoon-effect

Twins Effect

clones

Apple Style Portrait Effect

coldplay

Compositing Effect

compositing

Dimension Effect

dimension

Blue Glow Dreamy Effect

dreamy

Ink Drops in Your Digital Compositions Effect

dropink

Super Slick Dusky Lighting Effect

earth effect

Electrifying Energy Beams Effect

electric

Eery-Eye Photo Effect

evil-eye-effect

Fairy Night Eye Effect

Fairy-Night

Fairy tale Effect

fairytale

Make your image look awesome with a few light effects

fewlights

Fire Lines Effect

firelines

Make Perfume Commercial

fragrance

Dirty Grunge Effect

grunge

Coloring Effect

guitar-girl

Photoshop Effect: Focus With Light

hand-light-effect

Speeding Car Effect

car-effect

The Maiden and Hummingbird Photo Manipulation

doll-effects

Design an Epic Fantasy Scene with Photoshop

fantasy-effects

Thermal Photo Effect

flame-effects

Create an Abstract Design with Curved Light Streaks

hand-effect

Dance Photo Effect

hip-hop-effect

Glowing Neon Effect

human-3d-effects

Fantasy Art Scene

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvc2lsZW50by5qcGc=

Sexy Model with Glowing Bubbles Effect

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcGhvdG9fZWZmZWN0cy8xMHN0ZXBzMi5qcGc=

Glamour model

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcGhvdG9fZWZmZWN0cy9hZG9iZXR1dG9yaWFsei5qcGc=

Create an Amazing A.I. Robot Woman in Photoshop

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcGhvdG9fZWZmZWN0cy9kZXNpZ25yZXZpdmVyLmpwZw==

Impressive Photo Effect

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcGhvdG9fZWZmZWN0cy9waG90b3Nob3A4eC5qcGc=

Make Perfect Selection for Human Object by Utilising Channel Mask Technique in Photoshop

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcGhvdG9fZWZmZWN0cy9wc2R2YXVsdC5qcGc=

Create a Realistic Break-Apart Effect with Debris Brushset in Photoshop

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcGhvdG9fZWZmZWN0cy9wc2R2YXVsdDIuanBn

Create sexy cyborg Effect

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcGhvdG9fZWZmZWN0cy9wc2RlbHV4ZS5qcGc=

Create a Stylish Two-Tone Photo Montage Effect

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcGhvdG9fZWZmZWN0cy9wc2RmYW4uanBn

Design a Stylish Fashion Advert Effect

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcGhvdG9fZWZmZWN0cy9wc2RmYW4yLmpwZw==

Create a Divine Angel Montage Effect in Photoshop

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcGhvdG9fZWZmZWN0cy90dXRvcmlhbDkyLmpwZw==

Text Image Effect

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcGhvdG9fZWZmZWN0cy90dXRvcmlhbHBhcmsuanBn

Dynamic Scene with a Fallen Angel Effect

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcGhvdG9fZWZmZWN0cy90dXRzcGx1czMuanBn

Combine Photo Elements to Create a Surreal Photo Manipulation Effect

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcGhvdG9zaG9wdHV0b3JpYWxzLnBuZw==

Fairy and Sunset Landscape Effect

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcHN3aXNoLmpwZw==

Photo Manipulation - Creating a Fantasy Scene

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcHNkcm9ja3N0YXIuanBn

The Soft Sea Light

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcHNkdG9wLmpwZw==

Awesome Fantasy Style Castle Scene Creation in Photoshop

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvcHNkdmF1bHQuanBn

Fantasy Photo Manipulation Effect

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvdHV0c3BsdXM0LmpwZw==

Fantasy Creature in a Misty Landscape

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvdHV0c3BsdXMuanBn

Create an Out of Bounds Fantasy Illustration Effect

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvdHV0c3BsdXMyLmpwZw==

Making of a Forest Magical Scene

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvMTBzdGVwcy5qcGc=

Making of Urban Effect

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvY2dhcmVuYS5qcGc=

Create a Magic Crystal Ball

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvYWRvYmV0dXRvcmlhbHouanBn

Warth Best Life

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvYWRvYmV0dXRvcmlhbHoyLmpwZw==

Fantastic Tree

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvYWxmb2FydC5qcGc=

Magic lamp in the old room

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvYWxmb2FydDIuanBn

Fantastic Water Landscape

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvYWxmb2FydDMuanBn

Matte painting

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvZXllc29udHV0b3JpYWxzLmpwZw==

Magic Book

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvZXllc29udHV0b3JpYWxzMi5qcGc=

Serenity Prayer

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvZXllc29udHV0b3JpYWxzMy5qcGc=

Galaxy Angel

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMvZXllc29udHV0b3JpYWxzNC5qcGc=

Badass Bling Effect in Photoshop

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMyL2dvbWVkaWF6aW5lLmpwZw==

Flying Girl in Photoshop

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMyL2FiZHV6ZWVkby5qcGc=

Really cool Eclipse Effect in Photosho

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMyL2FiZHV6ZWVkbzIuanBn

X-MEN movie poster

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMyL2Fkb2JldHV0b3JpYWx6LmpwZw==

How to create a stylish mad lady in photoshop

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMyL2Jlc3RwaG90b3Nob3B0dXRvcmlhbHMuanBn

Fantasy light effects in Photoshop

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMyL2RpZ2l0YWxhcnRzb25saW5lMi5qcGc=

Lighting effects in Photoshop

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMyL2RpZ2l0YWxhcnRzb25saW5lMy5qcGc=

Make incredible surreal images

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMyL2RpZ2l0YWxhcnRzb25saW5lNC5qcGc=

Dazzling Dance Photo Manipulation Effect

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMyL3Bob3Rvc2hvcHR1dG9yaWFscy5wbmc=

Light and Glow Effect In Photoshop

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMyL3NlY29uZHBpY3R1cmUuanBn

Energize Your Graphics with Abstract Energy Lines

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMyL3R1dG9yaWFsOS5qcGc=

Ps Advanced Splatter Effect Tutorial

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMyL3R1dGNhbmR5LmpwZw==

Lighting Effect in Photoshop

L2hvbWUzL3BzZGVsdXhlL3B1YmxpY19odG1sL2ltYWdlcy9zdG9yaWVzL3dlYnR1dHMyLzEwc3RlcHMuanBn

Creative Photoshop Animal King Photo Manipulation Tutorial

anime-king-effects

Robotic Frog

frog

How to Create a Flying Land Illustration On Fire

knight-story-effects

Watercolor Effect

light-girl-effects

Alien Invasion

invasion-effects

Creating Energy Spheres

light-beam

Seriously Cool Photoshop Explosion Effect

light-effect

Lightning from hand

lighting-effects

Adding Light Streaks Effect To A Photo

lights

How To Make Circle Pixels Effect

lines-effect

Giving A Mafia-Look Effect

mafia

Design an Awesome Space Dancer Scene Effect

magic-effects

The Little Mermaid Photo Effect

mermaid

Design a wolf howling at the moon effect

midnight-effects

Light Effect On A Model

modern-effect

How To Turn Your Photo Into Movie-Like Effect

movie-effect

Dynamic Lightning Effect

building

Dark Art Picture Style Effect

night-effect

The Ocean Girl Photo Effect

ocean

How To Make Digital Photos Look Like Lomo Photography Effect

old-effects

Age Progression

old-lady-effect

Creating an Abstract Watercolor Effect

painting-effects

Fiery Photoshop Space Explosion Effect

planet-effect

Add Realistic Rainbow Effect To A Photo

ranbow-effect

Fantastic Disintegration Effect

rawr-effects

Realistic Water Reflection Effect

reflect-effect

Grunge Photo Edges Effect

shouting-effects

Add A Sparkle Trail Effect To A Photo

sparkle

How to Place a Use lighting effects to make photos sparkle

sparkle02

Creating Light Motion Trails & Glowing Sparks Effect

sparks

Christmas Fairy Magic Effect

star-effects

Bringing A Stone Statue To Life Effect

state-effects

How to Turn Humdrum Photos into Cinematic Portraits

storm-effects

Colorful Picture Style Effect

strong-impression

Realistic Tattoos Effect

tatoo-effect

Cool Halftone Effect

text-effect

How to make a Typographic, Retro, Space Face Effect

topology-effect

Photo Editing / Retouching

tragic

How to Apply Textures to Uneven Surfaces

tree-effects

Create a fantasy illustration in Photoshop

unicorn-effects

Urban-Style Piece Of Artwork

urban

Watchmen Effect

watchman-effects

Make an Apple Coldplay Style Ad in Photoshop

welcome-effect

Zombie Effect

zombie-effect

Halftone Dots And Linear Light

3315027899_4deff3e472

Beautiful Lady Effect

3315027947_3b5fe05642

Mosaic, Fill A Photo With Photos Effect

3315028177_dfda4429b6

Creating A Rocking Silhouette

3315028369_d29730bbd1

Make Photos More Suggestive

3315028409_7f18db32d7

Adding Reflections To Sunglasses Effect

3315028555_e6cf210930

Devil's Eye Effect

3315854678_0ee80c73ea

Fantasy Art

3315855042_3dd0fdbdb2

Retro Comic Book Effect

comic-effect

Water effect photo montage

wave

Vibrant Image Effect Using Photoshop

dance-effect

Ghost Effect

ghost

Dramatic gritty effect

Dramatic-gritty-effect

Photo to Illustration Effect

photo-to-illustrator

Turn A Photo Into A Collage Of Polaroids In Photoshop

Collage-Polaroids-Photoshop

Instant Photo To Oil Painting Action

Instant-Photo-To-Oil-Painting-Action

Photo to sketch Effect

soft-contrast-2

Pop Art Silkscreen Effect

pop-art-silkscreen-350

The Louis Daguerre Effect

daguerre-photo-effect-final

Cubism Effect

cubic-effect

Cross-Processing Effect

cross-effect

Create an Illustrated Look From a Photograph

photo-to-drawing

Super mysterious lighting effects for your image

sun-effect

HDR Effect Tutorial

HDR-tutorial

FAKE MODEL PHOTOGRAPHY EFFECT

fake-photography-effect

Photo to stencil Effect

Photo-to-stencil

Transform your Photos into a Beautiful Mosaic

picture-mosaic-14

Panoramas on Steroids Effect

panographyfeature

Pop Art Effect

Pop-Art

Filtering Out Colours

filter-color

City Globe Effect

city-global

Vintage photo effect

Vintage-photo-effect

Selective Sepia Effect

Selective-Sepia

Photoshop Rain Effect

photoshop-rain

Soft Glow Effects

slow-glow-effect

Charcoal Effect

charcoal-drawing-photoshop

High-Key B&W Portrait Effect

high-key01

Horror Film Effect

Horror-Film-Effect

Snow Effect

Snow-effect

HDR - High Dynamic Range Photography

HDR

English Tea can Painting Effect

English-Tea-can-Painting

Realistic Spotlight Effect in Photoshop

Realistic-Spotlight-Effect-Photoshop

Better negative effect

negative-effect

Dave Hill Look Effect

dave-hill-photoshop

Frosted Pixels Effect

Frosted-Pixels

Darklight Photomanipulation

Darklight-Photomanipulation

Blue Print Effect

blue-print-effect

PIXEL STRETCH EFFECT

pixel-stretch

OLD MOVIE EFFECT

old-movie

REALISTIC FOG & MIST EFFECT

realistic-fog-mist-effect

The Night Vision Thing Effect

night-vision-2

A Realist Painting Effect

realistic-painting

Hot & Fiery Photo Effect

Hot-Fiery-Photo-Effect

Trippy Colors Photo effect Tutorial

trippy_color_effect_preview

Digital Painting with Light

Digital-Painting-Light

Displacement Water Effect

Displacement-Water-effect

Creating a 3D effect with image editing software

3d-pop-out

India Movie Look

movie-look

Faking Depth Of Field Effect

Depth_Of_Field

Infrared Photo Effect

infraned-effect

Blurry TV Effect

blurry-tv-effect

PUZZLE PATTERN EFFECT

puzzle-effect

Face painting on cracked wall Tutorial

Face-on-Cracked-wall

Create photo mosaics effect

photo-mosaics

Bourne Ultimatum Color and Motion Blur Effect

Bourne-Ultimatum-Color-and-Motion-Blur

Cast Light From A Window Effect

window-light-effect

Stylized paint effect

Stylized-paint-effect

Night shooting effect

Night-shooting-effect

Give Your Photos a Color Ink Sketch Effect

Color-Ink-Sketch-Effect

Wicked Blast Effect

Wicked-Blast

Fix Perspective Effect

fix-perspective

Sharpen with Edge Mask

sharpen-edge

Making Your Subject Pop Out Of A Photo

photo-pop-out

Telling Stories With Shadows

superman

Digital Pixel Effect

digital-pixel

Tearing A Photo To Reveal Another

tear-effect

Worn, Torn Photo Edges Effect In Photoshop

photoshop-worn-torn-photo-edges

image-hard-light

Mirror Image Effect In Photoshop

photoshop-mirror-image-effect

Placing An Image Inside Of Another In Photoshop

tv-image

Create A Starry Sky In Photoshop

starry-sky

Photo Into a Beautiful Painting

tutorial-how-to-turn-a-photo-into-a-beautiful-painting-in-photoshop

 

Summery

Finally, this article has ended (after 200 tutorial i lost count). This really eats a lot of my time but i think it is worthwhile since i can refer back to it every single time and won't find myself in 'where's that tutorial again' situation. Nonetheless, if any of you are using this too, please throw in more photoshop photo effect tutorial that can benefit us all. Enjoy 🙂

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.