Friday, October 2, 2009

Validation (Select ,selectedCount,checkpassword) - Javascript

//

function setSelectOptions(the_form, the_select, do_check)
{
var selectObject = document.forms[the_form].elements[the_select];
var selectCount = selectObject.length;

for (var i = 0; i < selectCount; i++) {
selectObject.options[i].selected = do_check;
} // end for

return true;
}



function selectedCount(the_form, the_select)
{
var count = 0;
var selectObject = document.forms[the_form].elements[the_select];
var selectCount = selectObject.length;

for (var i = 0; i < selectCount; i++) {
if (selectObject.options[i].selected) count = count + 1;
} // end for

return count;
}



function checkpassword()
{

if(document.getElementById("oldpassword").value == "")
{
alert("Pleae Enter Old Password Value");
document.getElementById("oldpassword").focus();
return false;
}
if(document.getElementById("newpassword").value == "")
{
alert("Pleae Enter New Password Value");
document.getElementById("newpassword").focus();
return false;
}
if(document.getElementById("confirmnewpassword").value == "")
{
alert("Pleae Enter Confirm New Password Value");
document.getElementById("confirmnewpassword").focus();
return false;
}
if(document.getElementById("newpassword").value != null && document.getElementById("confirmnewpassword").value != null)
{
if(document.getElementById("newpassword").value != document.getElementById("confirmnewpassword").value)
{
alert("New Password AND Confirm New Password should be same");
document.getElementById("newpassword").value = "";
document.getElementById("confirmnewpassword").value = "";
document.getElementById("newpassword").focus();
return false;
}
}
}

//


Disclaimer: Any code or advice given is for instructional purposes only. We will not be responsible for any loss or damage caused by using this script

1 comment:

incion said...

Thanks for the coding Scripts.
I have bookmarked your page for the further reference help in future.
Professional Web Design