Posts Tagged ‘jquery’

jquery validate plugin, show only one error at a time

$('#form').validate({
errorLabelContainer:'#errorContainer',
showErrors: function(errorMap, errorList) {

if(errorList.length)
{
$('#errorContainer').html(errorList[0]['message']);
}
},
highlight:function(element,errorClass){
$(element).parent('td').addClass('error');
},
unhighlight:function(element,errorClass){
$(element).parent('td').removeClass('error');
}
})

jquery validate plugin with ajax duplicate check

jQuery validate plugin is pretty awsome. However it doesn’t do everything. That’s why the plugin have the addMethod function. And I need to add an ajax duplicate check for an email input. Here’s the method i wrote. There might be a better way. I would love to know.

jQuery.validator.addMethod("checkForDupeEmail", function(value, element, param){

var ajaxFunc = $.ajax({
async:false,   //we have to set it to false, it does not return a value before we even complete the request.
data:'email='+($.trim(value)),
type:'POST',
url:'/employees/ajax_checkDupe',
dataType:'text',
});
//here we check the response


if(ajaxFunc.responseText == 1)

return >true;

else

return >false;
});

Shadow Menu

Shadow Menu is a simple dropdown menu with a little animation.

1

see demo

ShadowMenu -- Download (180)

load jquery for firebug console

javascript:void((function(){j=document.createElement("SCRIPT");j.src="http://code.jquery.com/jquery-latest.pack.js";document.getElementsByTagName("HEAD")[0].appendChild(j);})())

you put this in your address bar and hit enter. Bookmarking it would help a lot also.

of course, i didnt write it. I also forgot where i found it too.

Jquery select text on focus or click

$('input').focus(function(){
    this.select();
});

Cakephp custom dropdown menu/select element

[UPDATED to allow multiple instances]
[UPDATED bug fix]

Hello everyone. The select tag that comes with html is pretty useful, but once in a while, one of your clients complains that it’s fugly. So you need to make  a custom one. And that’s what i just did. Damned clients!

Requirements:

  • jquery

To do this you need to create a file called customSelect.ctp in your app/views/elements folder(Of course you don’t NEED cakephp to use this.).

And the content said file would be(This example is for a category select menu.):
Read the rest of this entry »

Game of life, jquery implementation

Game of life in javascript/jquery flavor.
Rules:
  • For a space that is ‘populated’:
    • Each cell with one or no neighbors dies, as if by loneliness.
    • Each cell with four or more neighbors dies, as if by overpopulation.
    • Each cell with two or three neighbors survives.
  • For a space that is ‘empty’ or ‘unpopulated’
    • Each cell with three neighbors becomes populated.

Notes:

  • runs much faster in Chrome.
  • broken and runs like crap in all versions of ie
place holder
Round: