jQuery code to detect whether form fields have the default value when a checkbox is unchecked
There're multiple ways to do that. You should use a loop.

I've wrote a small script, that would do the job. I do not know if the if block is correct but you should easily fix that with this base.



$(document).ready(function(){
$('input[name="table_exist"]').click(function(){
 var table_exist_checked = $('input[name="table_exist"]').is(':checked');
 
 var fields = [
  'table_name',
  'user_id',
  'user_name',
  'user_email',
  'user_pass',
  'joining_date',
 ]; // Your field names
 
 // iterate over all fieldnames
 for(var index of fields) {
  var fieldName = fields[index]; // extract current fieldName
  var $elem = $('input[name="' + fieldName + '"]'); // save current element so we do not need to repeat
  
  // This is ur if-else. I do not exactly know if this is correct
   if($elem.val() == fieldName &amp;&amp; table_exist_checked){
   $elem.val('');
  } else if($elem.val()=='' &amp;&amp; !table_exist_checked){
   $elem.val(fieldName);
  }
 }
 
}); });