I have this input element with id "sku"
I am using this function
I'd like to use the same function for other elements too. How do I remove the hardcoded $("#sku") and make it generic so that I can pass any variable and the $("#sku") will be replaced by that variable ?
I am using jquery too.
I am using this function
Code:
sku.keyup(function(){
if($("#sku").val().length < 4)
{
$("#sku").attr("class","error");
}else
{
$("#sku").attr("class","ok");
}
})
Code:
$('#sku').blur(function(){
if($("#sku").val().length < 4)
{
$('#sku').attr("class","error");
}else
{
$('#sku').attr("class","ok");
}
})
I'd like to use the same function for other elements too. How do I remove the hardcoded $("#sku") and make it generic so that I can pass any variable and the $("#sku") will be replaced by that variable ?
I am using jquery too.