jQuery code to detect whether form fields have the default value when a checkbox is unchecked
1
$begingroup$
How could I rewrite this jquery code to compact it in a more elegant form:
$(document).ready(function(){ $('input[name="table_exist"]').click(function(){ if($('input[name="table_name"]').val()=='users' && $('input[name="table_exist"]').is(':checked')) { $('input[name="table_name"]').val(''); } else if($('input[name="table_name"]').val()=='' && !$('input[name="table_exist"]').is(':checked')) { $('input[name="table_name"]').val('users'); } if($('input[name="user_id"]').val()=='user_id' && $('input[name="table_exist&