how to keep a function from returning true twice with jquery -
i not "programmer" html/css hack trying write little jquery widget. not best format question here, know that, open edits , reworking make quality question. widget jsfiddle
$(document).ready(function () { function titleinc() { var length = $('#title').val().length; if (length >= 5 && length <= 10) { return true; // if returned true, don't return true again } else { return false; } } $('#title').blur(function () { var current = parseint($('#end_val').val(), 10); if (titleinc) { $('#end_val').val(current + 12); } }); });
basically score keeping tool. challenge if function keeps returning true person gets many points. function checking char value of input. if between 2 values person should points. shouldn't more if go input , retab out.
if onchange below/above false if onchange in range true if onchange still ok null
any ideas?
try this
$(document).ready(function () { var check = false; function titleinc() { var length = $('#title').val().length; if (length >= 20 && length <= 120 && !check) { check = true; return true; } return false; } $('#content-title-field').blur(function () { var current = parseint($('.dial').val(), 10); if (titleinc()) { $('.end_val').val(current + 12); } }); });
Comments
Post a Comment