0

I have a survey of which I want to record a user starting to complete it, by capturing the very first change in any input field or textarea.

So, if all fields (except hidden fields) are blank and any input / textarea change() is detected, I want to run the function rec_start.

if( allBlank ) { rec_start(); }

How can I detect allBlank? I asked this question here but added the hidden fields exception too late ... I'll accept answers in both question once I have a working solution.

Thanks

3
  • you can use it $("input[type='text']") to select only textboxes. Commented Apr 9, 2011 at 8:59
  • Don't need to select only textboxes. I need all input fields except hidden ones. Commented Apr 9, 2011 at 9:00
  • $(document).ready(function(){ $('input:not(:hidden)').......; }); Commented Apr 9, 2011 at 9:37

1 Answer 1

0

You want to check for a change in a field e.g.

<script>
    $('input').change(function(){
        if( ($(this).val()=='' || $(this).val()=='the_default_value') && $(this).attr('type')!='hidden') { // might want to do the default value using $.data and looping through $(input) and storing their $(this).attr('value') in $.data
            //the field is empty react as you may
        }
    });
</script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.