I want to do a simple check that an input field on one of my forms has text entered and if it does move the progress indicator towards 16 if it doesnt do nothing.
Clearly I’m missing something simple here but shouldn’t I just be able to check that the val is greater than 1 here?
Here is the coffee-
jQuery ->
$("#user_first_name").blur (event) ->
if $(this).val > 1
setInterval (->
front_index_gage.refresh 16
), 500
else
Is this an error in my coffee syntax?
=======UPDATE=============
After ensuring that the first field check worked it seems that this isnt the most elegant solution as this is the path I would be going down
jQuery ->
$("#user_first_name").blur (event) ->
if $(this).val().length > 1
setInterval (->
front_index_gage.refresh 16
), 500
else
jQuery ->
$("#user_last_name").blur (event) ->
if $(this).val().length > 1
setInterval (->
front_index_gage.refresh 33
), 500
else
setInterval (->
front_index_gage.refresh 16
), 500
with 6 form fields to check fairly new to js and coffee but is this a case where I would use a switch conditional to check and refresh the progress indicator?
Thanks again for your attention
“has text entered” means “there is one character or more in the value “, i.e. “the length is > 0″. You’re comparing the value itself.