Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
Campo de entrada de solo lectura cuando tiene valor de la base de datos; de lo contrario, cuando es nulo, debería ser editable

Soy nuevo en esta comunidad, su ayuda es muy apreciada. Esta es mi línea de código:

<input type="text" class="form-control" id="fines" name="fines" placeholder = "Amount Penalty" required>

Mi código Javascript:

 $(document).ready (function(){ if($(this).val()==""){ $('#fines').attr('readOnly','false'); } }); </script>``` The thing that I want to achieve is that when clicking the field with no value it must be editable and if it has a value from the database it will remain a read-only field. Your help is highly appreciated thank you!!
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede hacer algo como esto, ya que está utilizando una variable php para la entrada de texto.

Método 1:-

 <?php if( $row['fines'] == '' || $row['fines'] == NULL){ echo '<input type="text" class="form-control" value="" id="fines" name="fines" placeholder = "Amount Penalty" required>'; } else{ echo '<input type="text" class="form-control" value="'.$row['fines'].'" id="fines" name="fines" placeholder = "Amount Penalty" readonly>'; } ?>

Método 2:-

 <?php if( $row['fines'] == '' || $row['fines'] == NULL){ echo '<input type="text" class="form-control" value="" id="fines" name="fines" placeholder = "Amount Penalty" required>'; } else{ echo $row['fines'];//Show it as plain text, ez } ?>

Para tener en cuenta: - Cuando usa el Method 1:- todavía hay posibilidades de hacer que el texto de entrada se pueda escribir, solo inspeccionarlo y cambiar el valor sería bastante fácil para un usuario, creo que el Method 2:- es mucho mejor.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!