Validate form

0

I need to validate the fields of a form with jquery and I already had some but this form is written in php and it does not come out, This is the code of the form

<form name='frmUpdEspecialidades' id='frmUpdEspecialidades' action='qryEspecialidades.php' method='POST'>
                <table align='center' width='430'>
                    <tr height='100'>
                        <td colspan='2' align='center'>
                            <b>Modificando especialidades</b>
                            <input type='hidden' id='hdnOpc' name='hdnOpc'>
                            <input type='hidden' id='hdnId' name='hdnId'>
                        </td>
                    </tr>
                    <tr>
                        <td>Id</td>
                        <td>$id</td>
                    </tr>
                    <tr>
                        <td>Clave</td>
                        <td><input type='text' id='txtClave' name='txtClave' value='$clave'>
                        </td>
                    </tr>
                    <tr>
                        <td>Nombre</td>
                        <td><input type='text' id='txtNombre' name='txtNombre' value='$nombre'>
                        </td>
                    </tr>
                    <tr>
                        <td colspan='2' align='center'>
                        <input type='button' id='btnGrabar' name='btnGrabar' value='Grabar' style='width:100px' onClick='enviar(\"modificar\")'>
                        </td>
                    </tr>

and this is the jquery code I'm using

function validarFormulario(){
    $("#frmUpdEspecialidades").validate();
}

I already send the url of jquery and even then it does not work I keep recording the data even if there are empty fields

    
asked by Anderviver 11.10.2017 в 02:19
source

1 answer

0

For a basic validation using the jquery plugin validate it is necessary that the inputs you want to validate have the required tag as follows

<input type='text' id='txtClave' name='txtClave' value='$clave' required>

The javascript should look like this:

$(document).ready(function() {
    $("#frmUpdEspecialidades").validate();
});

To see more detail of the use of the plugin you can see this example

    
answered by 11.10.2017 в 02:40