I believe you're on the right track, but instead of $("#___").click()
, you should submit the form instead of invoking click on something.
Also, in your if
statement, you are using a DOM element, when you should be using a jQuery object. $(this)
as opposed to this
$("form#theForm").submit()
http://api.jquery.com/submit/
Final code would look like,
$('#text_field').keyup(function(){
if($(this).value.length ==8)
$('form#myForm').submit();
});
Also, i wanted to note that since you are using rails, you should use Coffee. It's much nicer.