Hello, I'm new with Jquery and I have a problem with the validation plugin.
The scenario is as follow:
I have 4 files:
1. An html file with a link.
- <!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>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <title>Cargador de B</title>
- <script type="text/javascript" src="jquery_min.js"></script>
- <script type="text/javascript" src="jquery.validate.min.js"></script>
- <script type="text/javascript" src="js/a.js"></script>
- </head>
-
- <body>
- <div><a href="#" id="cargarb">Pincha para cargar asíncronamente la página B</a></div>
- <div id="destinob"></div>
- </body>
- </html>
2. An java script file that catch the click event in the first file and execute an .ajax() function to load form in other div.
- var $j = jQuery.noConflict();
- $j(document).ready(function(){
-
- $j("a#cargarb").click( function()
- {
- $j.ajax(
- {
- url:'b.php',
- success: function(resultado)
- {
- $j('#destinob').html(resultado);
- $j.getScript('js/b.js');
- }
- });
-
-
- return false;
- }
- );
-
-
- });
3. Php file with the html code for the form to validate.
- <form class="regForm" id="login_form" name="form1" method="post" action="">
- <fieldset>
- <legend>Formulario de Ingreso</legend>
- <p>
- <label for="reg_email">Email:</label>
- <input type="text" name="reg_email" id="reg_email">
- </p>
- <p>
- <label for="reg_password">Clave</label>
- <input type="password" name="reg_password" id="reg_password">
- </p>
- <p>
- <label for="reg_sesion">No cerrar sesión</label>
- <input type="checkbox" name="reg_sesion" id="reg_sesion">
- </p>
- </fieldset>
- <p>
- <input type="submit" name="reg_submit" id="reg_submit" value="Ingresar">
- <input type="reset" name="reg_clean" id="reg_clean" value="Limpiar">
- </p>
-
- </form>
4. The last one file is a Javascritpt file tha use the validate function over the form in the php file.
- $j("#login_form").validate({
- rules:{
- reg_email: {
- required: true,
- email: true
- },
- reg_password:{
- required: true
- }
- },
- messages:{
- reg_email: {
- required: "Ingrese su Email",
- email: "Ingrese un email válido"
- },
- reg_password:{
- required: "Escriba una contraseña"
- }
- }
- });
This code works for all web browser except Internet Explorer (Any version).
Im using the latest version of jquery and the validation plugin.
I note if I put the form, the validation script in the same file. The code works fine in all web browsers.
Example.
html file
- <!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>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- <script src="jquery_min.js" language="JavaScript"></script>
- <script src="jquery.validate.min.js" language="JavaScript"></script>
- <script src="validate.js" language="JavaScript"></script>
- </head>
- <body>
- <form id="login_form" name="form1" method="post" action="">
- <fieldset>
- <legend>Formulario de Ingreso</legend>
- <p>
- <label for="reg_email">Email:</label>
- <input type="text" name="reg_email" id="reg_email">
- </p>
- <p>
- <label for="reg_password">Clave</label>
- <input type="password" name="reg_password" id="reg_password">
- </p>
- <p>
- <label for="reg_sesion">No cerrar sesión</label>
- <input type="checkbox" name="reg_sesion" id="reg_sesion">
- </p>
- </fieldset>
- <p>
- <input type="submit" name="reg_submit" id="reg_submit" value="Ingresar">
- <input type="reset" name="reg_clean" id="reg_clean" value="Limpiar">
- </p>
- </form>
- </body>
- </html>
the js file
- $(document).ready(function(){
- $("#login_form").validate({
- rules:{
- reg_email: {
- required: true,
- email: true
- },
- reg_password:{
- required: true
- }
- },
- messages:{
- reg_email: {
- required: "Ingrese su Email",
- email: "Ingrese un email válido"
- },
- reg_password:{
- required: "Escriba una contraseña"
- }
- }
- });
- });
I need the form appear when I click in the link.
The problem looks like when the validation is call in other file.
Thanks
Jose