lo trato de hacer con la libreria jquery
Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script src="js/jquery.js" type="text/javascript"></script> <script src="js/jquery.validate.js" type="text/javascript"></script> <script src="js/jquery.metadata.js" type="text/javascript"></script> <script type="text/javascript"> // ----------------------------------------------------------------------------------------- // // VALIDAR PRODUCTOS AL COTIZAR // // ----------------------------------------------------------------------------------------- // $(document).ready(function() { $("#form1").validate({meta: "validate"}); var ckb_sel = $("#ckb_sel"); }); </script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sin título</title> </head> <body> <form id="form1" name="form1" method="post" action="#"> <table width="880" border="1" align="center"> <tr> <td width="74">Disponible</td> <td width="255">Nombre</td> <td width="315">Apellido</td> <td width="208">Telefono</td> </tr> <?php for($i=0; $i<=5; $i++) { ?> <tr> <td><input type="checkbox" name="ckb_sel[<?php echo $i; ?>]" id="ckb_sel[<?php echo $i; ?>]" /> </td> <td> <input type="text" name="txt_nombre[<?php echo $i; ?>]" id="txt_nombre[<?php echo $i; ?>]" class="{validate:{required:true}}"/></td> <td> <input type="text" name="txt_apellido[<?php echo $i; ?>]" id="txt_apellido[<?php echo $i; ?>]" class="{validate:{required:#ckb_sel:checked}}" /></td> <td> <input type="text" name="txt_telefono[<?php echo $i; ?>]" id="txt_telefono[<?php echo $i; ?>]" /></td> </tr> <?php } ?> </table> <div align="center"> <input type="submit" name="button" id="button" value="Enviar" /> </div> </form> </body> </html>