Alert google

Don't forget to +1 me!

Custom jQuery validation rules

Posted by on Mar 23, 2012 in jQuery | 0 comments

I made some custom jQuery validation rules.

You can see my form here:
The name is the callback to the function of your custom jQuery validation rule.

$("#form").validate({
	rules:{
		fieldname: {
			POSTCODE : true,
			TELEFOON : true,
			elfproef : true
		}
	}
});

The fist custom jQuery validation rule:

You always start with

$.validator.addMethod("Name here"m function(value, element) {
	//Your rule
}, "Validation message");

we used the name TELEFOON to check dutch telephone numbers.
It returns true so you can say in the form TELEFOON : true
If the value of the element passes the reg test it returns true

//----- ### CUSTOM VALIDATION RULES ----//
$.validator.addMethod("TELEFOON", function(value, element) {
	return this.optional(element) || /^((\d{4}-\d{6})|(\d{10}))$/i.test(value);
}, "Vul een geldig telefoon nummer in.");

The second jQuery validation rule is for zip codes in holland.

It will check for zipcodes as 4 numbers with 2 letter with or without a -
like: 1234AB or 1234-AB it works the same as the Telephone check

$.validator.addMethod("POSTCODE", function(value, element) {
	return this.optional(element) || /^\d{4}[\s-]?[a-zA-Z]{2}$/i.test(value);
}, "Vul een geldig postcode.");

The last method is for dutch back account numbers.

It the so called elfproef.
Thats a way to check if its a valid number.
They way to check account numbers is described here http://en.wikipedia.org/wiki/Check_digit
If it succeeds it will return true else it will return false.

$.validator.addMethod("elfproef", function(value, element) {
	var sum=0;
	for (i=1; i<10; i++) {
		amount=value.charAt(i-1);
		sum+=amount*(10-i);
	}
	if (sum % 11==0 && value.length==9) {
		return true
	} else {
		return false
	}
}, "Vul hier een geldige bankrekeningnummer in.");
Read More

Elegant themes

Posted by on Mar 14, 2012 in Blog | 3 comments

Elegantthemes is owned by Nick Roach, an expert WordPress premium theme developer who creates all themes listed in Elegantthemes.com.
When he was thirteen, he needed to create a website for his band in the 7th grade.
That was the start of his career as web developer. He definitely got a lot better and his work is just awesome.

The theme’s on elegant themes are simple, clean and elegant. They all have unique items in them
The themes are coming with better, more unique and elegant designs.

Theme Functionality

Most of elegant themes are very user-friendly with features to allow users with no knowledge or skill in design/programming to adjust the website to their own style.

This is how the panel looks:
elegant themes screenshot

Each elegant theme has a widget ready sidebar, custom thumbnail images, search bar and alot more.
They have also special features such as a slider of recent posts, three level dropdown menu’s and alot more.
These are the reasons why Elegant themes is ranked on the Top 10 under theme functionality.

Elegant themes have high resolution graphics and most of the time various color schemes.
The colorful websites have an excellent contrast so viewers do not get distracted.

The background offers relaxing effects to make the viewers stay longer and browse more articles and read more content.
The header is the most import part of the website and is generally very stylish with an unique combination of font’s , sliders and bold titles.

As we speak today, 14 march 2012, a quote from elegant themes website

Elegant Themes provides, without a doubt, the most affordable themes on the net.
With a total of 74 designs in our collection, the price per theme is a mere $0.52!

Among all the premium WordPress themes in the world, we think Elegant themes has the most beautiful and unique designs and collection of themes.

For only $39,- dollar a year you can use all of their themes unlimited.
And of only $89,- a year you get all of the Adobe Photoshop documents!

You get always technical support until you stop the subscription.
However you still can use the themes! you just can’t update them and log in to the member area!

All I can say is! Do it!
If you need unique and beautiful themes for a low price! go to elegant themes and buy them!

Read More

Get current url in PHP

Posted by on Mar 14, 2012 in PHP | 0 comments

This is a simple trick to get the current URL with all the get Variables in PHP.

This is an easy way to get current url in PHP
With this code you return the current url.
It gets with the global $_SERVER['HTTP_HOST'] variable the hostname, for example on this website it would be www.peterotten.com
and with $_SERVER['REQUEST_URI'] everything behind the domain extension.

the $_SERVER global variable has more info stored about the server and the web page.
You can find the complete list here http://php.net/manual/en/reserved.variables.server.php

//get current url
function get_current_url(){
	$currenturl="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
	return $currenturl;
}
?>

With this code you echo the url

	get_current_url();
Read More