Como posso executar uma função em javascript dentro de código jquery?
Tenho o seginte código em javascript:
function validar(){
var usuario = document.getElementById("txtUsuario");
var senha = document.getElementById("txtSenha");
if(usuario.value == "" && senha.value == ""){
alert("informe seu nome de usuário e senha de acesso!");
formLogin.txtUsuario.focus();
return false;
}
if(usuario.value.length <= 8 && senha.value.length <= 8){
alert("nome de usuário / senha inválido!");
formLogin.txtSenha.focus();
return false;
}
if(usuario.value != "" && senha.value != ""){
if(usuario.value.length >= 8 && senha.value.length >= 8){
alert("olá " + usuario.value);
return false;
}
}
return true;
}
Quero chamar o código acima dentro do seguinte código em jquery:
$("btn").ready(function{
$(this).click();
});
OBS: ambos os códigos estão em arquivos separados.
Alguém poderia me ajudar?
Desde já agradeço a atenção.