1stwebdesigner |
5 Unusual Yet Great Ways To Make Money With Your Blog Posted: 03 May 2010 01:28 PM PDT Blogging has been growing in popularity since a couple of years. It started out as a way for people to publish their thoughts online, and for others to comment on them. What started as a few sentences of thought and personal opinion has evolved into thousands and thousands of articles and posts about anything. As blogging continues to become more advanced, the advertising and marketing world has tapped into its potential. Most Internet Marketers suggest you to put up adverts on your site to make money, but such solution needs a good blog traffic, and frankly in my experience there are many better ways to make money. So in this article I will be talking about the best ways a blog can make money. 1. Selling eBooks:This is something that has been increasingly more popular over the last couple years. The main reason is generating a respectable source of income for those with relevant and useful content to share. How Can I Sell My Ebooks ?There is several ways to sell your ebooks online :
2. Premium Membership:Recently, I have seen a lot of bloggers adding membership areas to their blogs. To do this you can add a new membership area where you can publish content for members only. And this is a good source for money but the content you offer must be original to your readers.In such sections you can also offer some freebies. You can take a look at the links above showing some famous blogs with membership areas: 3. Web Directories :Web Directories are places where job seekers can pay monthly to have themselves listed in a directory so people who are looking for them, can browse such place and pick their favorite. 4. Job Boards :All the popular blogs are trying to leverage job boards to make some extra income.Needless to say that in order to create an active and profitable job board you need first to have a blog focused on a specific niche, and a decent amount traffic.The advantage of this method is that it is passive. Once you have the structure in place, the job listings will come naturally, and you can charge anywhere from $10 up to $100 for each. There is a lot of job board softwares such as Webjobs, SimplyHired Job-o-matic … But there are two main Wordpress plugins that I recommend : WPJobBoard and JobPress. These plugins will allow you to add a Job Board to your blog. 5. Advertising :Advertising is a famous technique every blogger use to make money with his blog. And there is many ways to advertise on your blog, but the famous one for bloggers is direct banner advertising. Selling your own advertising space is one of the most lucrative monetization methods. First and foremost because it enables you to cut out the middleman commissions and to determine your own rates. The most popular banner formats on the web are the 728×90 leaderboard, the 120×600 skyscraper, the 300×250 rectangle and the 125×125 button. The downside of direct banner advertising is that you need to have a big audience to get qualified advertisers, and you will need to spend time managing the sales process, the banners and the payments. But there is websites that manage these functionalities and buy sell ads is one of the best. |
Building Real-Time Form Validation Using jQuery Posted: 03 May 2010 03:00 AM PDT Client-side validation is something every web form should have, no doubts about that. While server-side validation does its job, it certainly lacks good user experience. What is so great about client-side validation then? Not only is it useful to the user because it makes the process of filling out the form a lot quicker and a lot less painful, but it also shows that you actually care about them. For the user there’s nothing better than knowing right away if they’re doing it correctly. In this tutorial we’re going to learn how to build real-time form validation using jQuery. If you’d like to see what you’ll be building, you can watch the short video intro or hit the “Live Demo” button and check it out.
Table of Contents
How Will We Achieve That?Now, there are actually many ways to do that; here are the most common:
It will all work, but neither is the optimal way. Why? Because there’s too much messing with your HTML code and you’ll end up with bunch of needless tags that are required by your validation script, but which your form doesn’t really need. It’s clearly not the way to go, so instead we’re going to do this the way I do it myself. In my opinion it’s the best solution, although it’s not very common; I honestly have never came across this method, I’ve never seen it used by someone. But if you have, please let me know in the comments. OK, so what are we going to do?
That way we keep our HTML code nice and clean. Note: It’s vital to always provide server-side validation as well (for users with turned off JavaScript). Project StructureWe are going to need three files:
I’m gonna go roughly through the HTML coding, provide you with all needed CSS – and then focus mostly on our jQuery script, which is the most important thing and what we’re hoping to learn today. Coding the HTMLStep 1: Some Basic HTML and Importing jQuery + Validation ScriptFirst, make index.html file and put some basic code there; you can see that we imported jQuery at the bottom, along with our validation.js file, which will contain our validation script: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Real-Time Form Validation Using jQuery</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> </head> <body> <div id="content"> </div><!-- content --> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" charset="utf-8"></script> <script type="text/javascript" src="validate.js" charset="utf-8"></script> </body> </html> Step 2: The Form, Splitted Into Three SectionsWe’re going to split the form into three sections using
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Real-Time Form Validation Using jQuery</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> </head> <body> <div id="content"> <form id="jform" action="http://1stwebdesigner.com" method="post"> <fieldset> <legend>Personal Info</legend> </fieldset> <fieldset> <legend>Email</legend> </fieldset> <fieldset> <legend>About You</legend> </fieldset> </form> </div><!-- content --> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" charset="utf-8"></script> <script type="text/javascript" src="validate.js" charset="utf-8"></script> </body> </html> Step 3: Adding Fields + Submit ButtonGreat, now it’s time to finally add some fields to our form. For this tutorial we’re going to use several different fields:
We’re going to wrap every set ( Your final index.html file should look like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Real-Time Form Validation Using jQuery</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> </head> <body> <div id="content"> <form id="jform" action="http://1stwebdesigner.com" method="post"> <fieldset> <legend>Personal Info</legend> <p> <label for="fullname" class="block">Full name:</label> <input type="text" name="fullname" id="fullname" /> </p> <p> <label for="birthday" class="block">Day of birth <small>(dd-mm-yyyy)</small>:</label> <input type="text" name="birthday" id="birthday" /> </p> <p> <label class="block">I am:</label> <input type="radio" name="gender" id="man" value="man" /> <label for="man">Man</label> <input type="radio" name="gender" id="woman" value="woman" /> <label for="woman">Woman</label> </p> <p> <label class="block">I own:</label> <input type="checkbox" name="vehicle" id="car" /> <label for="car">car</label> <input type="checkbox" name="vehicle" id="airplane" /> <label for="airplane">airplane</label> <input type="checkbox" name="vehicle" id="bicycle" /> <label for="bicycle">bicycle</label> <input type="checkbox" name="vehicle" id="ship" /> <label for="ship">ship</label> </p> </fieldset> <fieldset> <legend>Email</legend> <p> <label for="email" class="block">Email <small>(mickey@mou.se)</small>:</label> <input type="text" name="email" id="email" /> </p> </fieldset> <fieldset> <legend>About You</legend> <p> <label for="about" class="block">Tell us a little bit about yourself:</label> <textarea id="about" cols="50" rows="10"></textarea> </p> </fieldset> <p> <button type="submit" id="send">submit</button> </p> </form> </div><!-- content --> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" charset="utf-8"></script> <script type="text/javascript" src="validate.js" charset="utf-8"></script> </body> </html> It may look a bit messy, but it’s because of the WP’s syntax highlighting plugin. It’s actually really clean, and that’s what we wanted to achieve afterall. Check it: save the above code as your index.html file, open it in your browser and look at the source code. Now it looks clean, isn’t it? Spicing It Up With CSSSince CSS styling is not our main focus in this tutorial, I’m not gonna go over this, but simply provide you with the CSS you’re going to need for this to work. Create style.css file, put inside all the code from below and that’s it! Now everything should look sweet. body { background: #efefef; margin: 0; padding: 0; border: none; text-align: center; font: normal 13px Georgia, "Times New Roman", Times, serif; color: #222; } #content { width: 500px; margin: 0 auto; margin-bottom: 25px; padding: 0; text-align: left; } fieldset { margin-top: 25px; padding: 15px; border: 1px solid #d1d1d1; -webkit-border-radius: 7px; -moz-border-radius: 7px; border-radius: 7px; } fieldset legend { font: normal 30px Verdana, Arial, Helvetica, sans-serif; text-shadow: 0 1px 1px #fff; letter-spacing: -1px; color: #273953; } input, textarea { padding: 3px; } label { cursor: pointer; } .block { display: block; } small { letter-spacing: 1px; font-size: 11px; font-style: italic; color: #9e9e9e; } .info { text-align: left; padding: 5px; font-size: 11px; color: #fff; position: absolute; display: none; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; -webkit-box-shadow: -1px 1px 2px #a9a9a9; -moz-box-shadow: -1px 1px 2px #a9a9a9; box-shadow: -1px 1px 2px #a9a9a9; } .error { background: #f60000; border: 3px solid #d50000; } .correct { background: #56d800; border: 3px solid #008000; } .wrong { font-weight: bold; color: #e90000; } .normal { font-weight: normal; color: #222; } #send { background: #3f5a81; width: 100%; border: 5px solid #0F1620; font: bold 30px Verdana, sans-serif; color: #fafafa; text-shadow: 1px 1px 1px #0F1620; -webkit-border-radius: 7px; -moz-border-radius: 7px; border-radius: 7px; } #send:hover { background: #4d76b1; border: 5px solid #253750; color: #fff; } #send:active { text-indent: -10px; } All The Fun: jQuery MagicThis is the most interesting and engaging part. First we need to do some thinking and describe our key points. Step 1: PlanningWe have to ask ourselves three questions before we can go on:
It’s obvious we want the script to validate our form. But how?
To reduce our global footpring, we’re going to use JavaScript Step: 2: What Do We Need?JS object, in our case it will be:
Methods of that object for each of the form fields, validating that particular field:
Variable which will hold the status of error occuring:
And method that will be called as the last one; it will check if there were any errors and submit the form if not. If some errors occurred, it will take the user to the beginning of the form, so they can fill it out again.
Now we can finally start building our validation script. When finish our first validation method, then it will be much easier and faster, as we can reuse it for other methods, only applying some changes. Let’s crack into it! Step 3: Our Script “Packaging”The start is really simple, almost everything will go inside this code: $(document).ready(function(){ jVal = { }; }); Step 4: Validating User’s NameOur first method will handle user’s name. Put it inside our var jVal = { 'fullName' : function() { } }; Now let’s put some first lines of code inside our method. Just paste it, and then I will explain what the code “says”: $('body').append('<div id="nameInfo" class="info"></div>'); var nameInfo = $('#nameInfo'); var ele = $('#fullname'); var pos = ele.offset();
Great, so far so good. It’s time to add some few more lines: nameInfo.css({ top: pos.top-3, left: pos.left+ele.width()+15 });
We’re doing really great, we just acomplished 50% of if(ele.val().length < 6) { jVal.errors = true; nameInfo.removeClass('correct').addClass('error').html('← at least 6 characters').show(); ele.removeClass('normal').addClass('wrong'); } else { nameInfo.removeClass('error').addClass('correct').html('√').show(); ele.removeClass('wrong').addClass('normal'); } Lot of weird crap, huh? Don’t worry, it’s not so scary as it may look:
Well done! This is our first validation method. Now it’s time to test it, but before we can do that, we need to write few more lines of code. We need to make sure, that our Paste this code below the whole $('#fullname').change(jVal.fullName); What it does in human words: if the user changes value of the “Full name” field and then leaves (e.g. to fill out another field), our Right now you should have one fully working validation method, so test it. Your whole validate.js file should like like this: $(document).ready(function(){ var jVal = { 'fullName' : function() { $('body').append('<div id="nameInfo" class="info"></div>'); var nameInfo = $('#nameInfo'); var ele = $('#fullname'); var pos = ele.offset(); nameInfo.css({ top: pos.top-3, left: pos.left+ele.width()+15 }); if(ele.val().length < 6) { jVal.errors = true; nameInfo.removeClass('correct').addClass('error').html('← at least 6 characters').show(); ele.removeClass('normal').addClass('wrong'); } else { nameInfo.removeClass('error').addClass('correct').html('√').show(); ele.removeClass('wrong').addClass('normal'); } } }; // bind jVal.fullName function to "Full name" form field $('#fullname').change(jVal.fullName); }); Step 5: Validating User’s Date of BirthStarting from now, it will all get easier. Our validation methods are in 90% the same, so all you have to do is copy our Great, so now just copy whole
This is how 'birthDate' : function (){ $('body').append('<div id="birthInfo" class="info"></div>'); var birthInfo = $('#birthInfo'); var ele = $('#birthday'); var pos = ele.offset(); birthInfo.css({ top: pos.top-3, left: pos.left+ele.width()+15 }); var patt = /^[0-9]{2}\-[0-9]{2}\-[0-9]{4}$/i; if(!patt.test(ele.val())) { jVal.errors = true; birthInfo.removeClass('correct').addClass('error').html('← type in date in correct format').show(); ele.removeClass('normal').addClass('wrong'); } else { birthInfo.removeClass('error').addClass('correct').html('√').show(); ele.removeClass('wrong').addClass('normal'); } }
And of course, we need to bind this $('#birthday').change(jVal.birthDate); And we have another fully working validation method. Great job! Step 6: Validating User’s GenderAgain, simply copy the whole
This is how 'gender' : function (){ $('body').append('<div id="genderInfo" class="info"></div>'); var genderInfo = $('#genderInfo'); var ele = $('#woman'); var pos = ele.offset(); genderInfo.css({ top: pos.top-10, left: pos.left+ele.width()+60 }); if($('input[name="gender"]:checked').length === 0) { jVal.errors = true; genderInfo.removeClass('correct').addClass('error').html('← are you a man or a woman?').show(); ele.removeClass('normal').addClass('wrong'); } else { genderInfo..removeClass('error').addClass('correct').html('√').show(); ele.removeClass('wrong').addClass('normal'); } }
As always, we have to bind this $('input[name="gender"]').change(jVal.gender); There, another validation method completed. Three more to go :). Step 7: Validating Vehicles Owned by UserThis time copy
This is how 'vehicle' : function (){ $('body').append('<div id="vehicleInfo" class="info"></div>'); var vehicleInfo = $('#vehicleInfo'); var ele = $('#ship'); var pos = ele.offset(); vehicleInfo.css({ top: pos.top-10, left: pos.left+ele.width()+40 }); if($('input[name="vehicle"]:checked').length <= 1) { jVal.errors = true; vehicleInfo.removeClass('correct').addClass('error').html('← I am sure you have at least two!').show(); ele.removeClass('normal').addClass('wrong'); } else { vehicleInfo.removeClass('error').addClass('correct').html('√').show(); ele.removeClass('wrong').addClass('normal'); } }
Again, we have to bind this $('input[name="vehicle"]').change(jVal.vehicle); Tired? We have couple more methods to cover :). Time for email validation. Step 8: Validating User’s Email AdressThis time, copy our
This is how 'email' : function() { $('body').append('<div id="emailInfo" class="info"></div>'); var emailInfo = $('#emailInfo'); var ele = $('#email'); var pos = ele.offset(); emailInfo.css({ top: pos.top-3, left: pos.left+ele.width()+15 }); var patt = /^.+@.+[.].{2,}$/i; if(!patt.test(ele.val())) { jVal.errors = true; emailInfo.removeClass('correct').addClass('error').html('← give me a valid email adress, ok?').show(); ele.removeClass('normal').addClass('wrong'); } else { emailInfo.removeClass('error').addClass('correct').html('√').show(); ele.removeClass('wrong').addClass('normal'); } }
Of course, bind this $('#email').change(jVal.email); Time for the last of our validation methods: Step 9: Validating User’s About InfoFor this last method, copy
This is how our 'about' : function() { $('body').append('<div id="aboutInfo" class="info"></div>'); var aboutInfo = $('#aboutInfo'); var ele = $('#about'); var pos = ele.offset(); aboutInfo.css({ top: pos.top-3, left: pos.left+ele.width()+15 }); if(ele.val().length < 75) { jVal.errors = true; aboutInfo.removeClass('correct').addClass('error').html('← come on, tell me a little bit more!').show(); ele.removeClass('normal').addClass('wrong').css({'font-weight': 'normal'}); } else { aboutInfo.removeClass('error').addClass('correct').html('√').show(); ele.removeClass('wrong').addClass('normal'); } } And of course we need to bind it to our “About” form field: $('#about').change(jVal.about); This is it! We just completed all our validation methods. It’s almost like they say: the end is nigh! There’s only two things left to do:
Step 10: Final |
You are subscribed to email updates from Graphic and Web Design Blog To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
Comments (0)
Post a Comment