I want to trim all the input element values on its blur. I defined a function trimElements and called
in a global page global.js. But in some pages I dont want this feature (trimming); but I already called in global.js. I am trying to nullify the affect of first called function through the second call of same function.
My code is here.
global.js
function trimElements(trim) {
if(trim) {
$("input,textarea").blur(function() {
$.each($("input"),function() {
$(this).val($.trim($(this).val()))
})
})
}
}
$(document).ready(function(){
trimElements(true);
});
In some other page I dont want this trim functionality. ie I am trying to do like following
$(document).ready(function(){
trimElements(false); // want to cancel the affect of first function call
});
But I am missing some thing in logic.
Just unbind the element with
falsehttp://jsfiddle.net/ExplosionPIlls/b9E47/