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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -