Archive for July, 2011

Simple confirm password or email validation

If you have a form with a ‘confirm password’ field or ‘confirm email’, and you don’t want to use a heavy validation plugin just for a simple confirmation like this, you can always use some simple ‘old school’ javascript and the onblur event, so when the field loses focus triggers the validation function.

<script type="text/javascript">
	function confirmPass() {
		var pass = document.getElementById("pass").value
		var confPass = document.getElementById("c_pass").value
		if(pass != confPass) {
			alert('Wrong confirm password !');
		}
	}
</script>
<form id="form" action="" method="post">
    <label for="pass">Password</label>
    <input type="password" id="pass" class="text" name="your_pass" value=""/>
    <label for="c_pass">Confirm Password</label>
    <input type="password" id="c_pass" class="text" name="your_c_pass" value="" onblur="confirmPass()"/>
</form>

See a demo.

Open flowplayer in fancybox

Flowplayer is a good choice when it comes to embedding videos into websites, …but what about flowplayer in fancybox ?

If you google a bit certainly you’ll find some ideas of how to play a video in flowplayer in fancybox, but by far the most simple one and the one that gives you the control on every option of every movie embedded, is to embed each of your videos in one different page (ex. lets say we have movie1.mp4 and movie2.mp4 then we should have /movie1.html and /movie2.html or if you have just one video then just one page ), and then set the ‘href’ of the link that is supposed to open that video to the URL of the video page, and now when you click on the link it will open the video page in an iframe in the modalbox. To easily understand this see the demo.

Take note of the snippet of code bellow when you set fancybox.

$("#video-link").fancybox({
	'width' : 336,
	'height' : 256,
	'overlayShow' : false,
	'autoScale' : false,
	'transitionIn' : 'none',
	'transitionOut' : 'none',
	'type' : 'iframe' //tweek the other, do not change this;
});

Demo