jquery - on change of textbox value, check condition on the basis of rails instance variable -
in rails application, have text-area value changes on basis of checkbox. text-area
<%= f.text_area :sent_to, :class => 'form-control'%>
on change of content of text-area, want count number of comma separated values in text-area , check if exceeds number stored in instance variable @org_msg_limit. instance variable have field promo_limit on basis of want check number of comma separated values in text-area. if value in text-area exceeds number in promo_limit display alert/message. how this?
i tried make hidden field set value of variable instance vairable
<%= hidden_field "trans_limit", :value => limit.trans_limit.to_i %>
than made .change function follows not working.
<script type="text/javascript"> $(document).ready(function(){ $('#sent_to').val().change(function() { alert("hello"); var limit = $('#trans_limit').val(); alert(limit); }); }); </script>
Comments
Post a Comment