Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/07/2012, 16:42
Lechu_
 
Fecha de Ingreso: enero-2010
Mensajes: 128
Antigüedad: 14 años, 3 meses
Puntos: 2
Pasar funcion javascript a JQuery

Quiero llamar a una funcion javascript desde jQuery.

La idea es llamar a la funcion javascript para evaluar lo que ingresa el usuario y segun el resultado imprimirlo por pantalla con JQuery.

HTML + JQuery + javascript

Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Red</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />

<!--<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>-->  

<script type="text/javascript" src="js/funciones.js"></script>
<script type="text/javascript" src="js/jquery-1.7.2.js"></script>


<script type="text/javascript">

$(document).ready(function(){
    $('#nombre').focusout( function(){
        if($('#nombre').val()!= ""){
            $.ajax({
                type: "POST",
                url: "validacionesvarias.php",
                data: "texto="+$('#nombre').val(),
                dataType:"json",
                beforeSend: function(){
                  $('#msgUsuario').html('<img src="images/ajax-loader.gif"/> verificando');
                },
                success: function( respuesta ){
                  if(respuesta == '1')
                    $('#msgUsuario').html("Disponible");
                  else
                    $('#msgUsuario').html("No Disponible");
                }
            });
        }
    });
    $('apellido').focusout(function(){
       if (valuar_apellido ($('#apellido').val())=='1'){
        $('#msgUsuario').html('Texto Uno');
       }else{
        $('#msgUsuario').html('Texto Dos');
       }
    });
});
</script>

</head>

<body>
<form id="frmRegistro">
    <label> Nick: </label>
    <input type="text" id="nombre" name="nombre"/><label id="msgUsuario">hola</label>
    <label> Apellido: </label>
    <input type="text" id="apellido" name="apellido"/><div id="a"></div>
    
    
</form>
</body>

funciones.js
Código:
function valuar_apellido (dato){
    var nom=dato;
        
    if (nom=='a'){
        return 1;
    }else{
        return 0;
    }
}
__________________
Por favor evitar comentarios del estilo "leer el manual...", ya lo hice pero aun tengo dudas, por eso pregunto acá