Thursday, June 24, 2010

JavaScript Examples

Hi, i would like to share some of the examples of JavaScript which can help to build the powerful, userfriendly applications.

1) How to dynamic load enable and disable images on image button depend on some conditions.

below is the example:

function EnableOrDisableSomeKey()
{
var textboxFirstName = document.forms[0].TextBox_First_Name;
var textboxLastName = document.forms[0].TextBox_Last_Name;
var textboxEmail = document.forms[0].TextBox_Email;

buttonNext.disabled = !((trimmedFirstName.length > 0) || (trimmedLastName.length > 0) || (trimmedEmail.length > 0);

if (buttonNext.disabled && buttonNext.src.indexOf('_Disabled') == -1)
buttonNext.src = buttonNext.src.replace('Next', 'Next_Disabled');
else if(!buttonNext.disabled && buttonNext.src.indexOf('_Disabled') > 0)
buttonNext.src = buttonNext.src.replace('_Disabled', '');

}