Very Hardcore Anime Fan

Posted by Guncannon @ 12:19 pm
Category: Random

Some anime fan can be so hardcore, that they need to create their own animation to show off how hardcore they are…

Read more »


Japanese Interpretation of Spiderman

Posted by Jetlogs @ 7:38 pm
Category: Humor

Have you ever wondered how the Japanese viewed the American comic book characters? Well, you need not to wonder anymore as this video whows the Japanized version of the spider-man series. Behold, the opening sequence to SUPAIDA-MAN!

The opening is totally reminiscent of a sentai, and yes, spider-man has a giant robot…


Genso Suikoden Tierkreis Confirmed for the DS

Posted by Jetlogs @ 12:40 pm
Category: Video Games

The latest issue of Famitsu has revealed a new addition for the Suikoden series, and the game is titled Genso Suikoden: Tierkreis

Suikoden Tierkreis

This comes as a major surprise since the Suikoden series has always been originally released on consoles. This will also be the first time that a Suikoden, a Playstation staple, will be released on a Nintendo console as well. How this game will be received on an entirely new audience will still remain to be seen.


Geek + Bikini = Geekini?

Posted by Guncannon @ 3:11 am
Category: Random

After the totally awsome Nintendo gamepad underwear, here comes something even more exciting. Take a look yourself.

As you can see, it is a bikini with a gamepad buttons on top.  Makes you really wanna play it doesn’t it? /gg  But why they called it Geekini?  I’m still clueless…


jQuery: Multiple Checkbox Validation

Posted by Jetlogs @ 11:52 am
Category: Web Development, jQuery

Having problems with checkbox validations? Then you’re not alone. Checkbox validation is usually more difficult due to its nature of having multiple values at the same time.

Consider this simple form where a user is required to select at least one checkbox:
Which of the following jQuery selectors do you usually use?
(Please select at least one)

#id

.class

element[@attribute]

Which of the following jQuery events do you usually encounter?
(Please select at least one)

click

focus

change

blur

submit

<b>Which of the following jQuery selectors
do you usually use? (Please select at least one)</b><br>
<input type="checkbox" name="selector[]"
id="selector" value="id">#id<br>
<input type="checkbox" name="selector[]"
id="selector" value="class">.class<br>
<input type="checkbox" name="selector[]"
id="selector" value="element">element[@attribute]<br><br>

<b>Which of the following jQuery events
do you usually encounter? (Please select at least one)</b><br>
<input type="checkbox" name="event[]"
id="event" value="click">click<br>
<input type="checkbox" name="event[]"
id="event" value="focus">focus<br>
<input type="checkbox" name="event[]"
id="event" value="change">change<br>
<input type="checkbox" name="event[]"
id="event" value="blur">blur<br>
<input type="checkbox" name="event[]"
id="event" value="submit">submit<br>

So how do we do the validation?

First we’ll have to bind the validations with the form’s submit event (submit() event on jQuery) and return false for all empty checkbox groups to prevent the form triggering its submission.

Without using jQuery, you’ll have to iterate through all of the checkbox elements, then check for the checked status of each individual check boxes (if none is checked then return false). And you’ll have to do this for each check box grouping.

However, jQuery makes things a little bit easier by introducing a selector filter for checked elements.
Using the :checked filter, it will select all of the checked elements for a particular element. so in this case,

$("input:checked")

will select all of the checked input elements. However, this is a downside for this. The :checked filter does not support #id and .class selectors so the following won’t work:

$("#selector:checked")
$("#event:checked")

So how do we work around this? Its pretty simple, by specifying the id, class, or even as an attribute, we can now separate the checkboxes according to its grouping. In this example, we are going to be using the #id to separate our checkboxes.

var selector_checked = $("input[@id=selector]:checked").length;
var event_checked = $("input[@id=event]:checked").length;
if (selector_checked == 0)
{
	return false;
}
else if (selector_checked == 0)
{
	return false;
}
else
{
	return true;
}

Its much simpler than iterating through each checkbox, since jQuery automatically does this for us. For two different checkbox groups, this is acceptable. However, when we would need to deal with more checkbox groupings, this can become a problem since the code will become more cluttered by then.

To simplify things, we’ll just make our own function passing the #id as a parameter to check for each checkbox group’s status. This is how the script would finally look like.

$(document).ready(function()
{
	$("form").submit(function()
	{
		if (!isCheckedById("selector"))
		{
			alert ("Please select at least one selector");
			return false;
		}
		else if (!isCheckedById("event"))
		{
			alert ("Please select at least one event");
			return false;
		}
		else
		{
			return true; //submit the form
		}
	});

	function isCheckedById(id)
	{
		var checked = $("input[@id="+id+"]:checked").length;
		if (checked == 0)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
});

Next Page »
  • Archives

  • Donations

  • Social Bookmarks

  • Jetlogs.org
    Some Rights Reserved 2007
    Creative Commons License