function validar()

{

if ( (document.frmContacto.nombre.value.length<3) || emailOK (document.frmContacto.email.value) )
 {
  alert("Indique al menos un nombre o E-mail válido");
  document.frmContacto.nombre.focus();
  return false;
 }
 
 if  (document.frmContacto.texto.value.length < 15) 
 {
  alert("Cuéntenos su caso: ¿ En que podemos ayudarle ?");
  document.frmContacto.texto.focus();
  return false;
 } 
 
 document.frmContacto.submit();

}


/**
*  Validar Email
*/

 function emailOK (emailStr) {
/* Verificar si el email tiene el formato user@dominio. */
var emailPat=/^(.+)@(.+)$/

/* Verificar la existencia de caracteres. ( ) < > @ , ; : \ " . [ ] */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"

/* Verifica los caracteres que son válidos en una dirección de email */
var validChars="\[^\\s" + specialChars + "\]"

var quotedUser="(\"[^\"]*\")"

/* Verifica si la dirección de email está representada con una dirección IP Válida */


var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/

/* Verificar caracteres inválidos */

var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
//alert("Email address seems incorrect (check @ and .'s)")
return false
}
var user=matchArray[1]
var domain=matchArray[2]

// Si el user "user" es valido 
if (user.match(userPat)==null) {
// Si no
//alert("El nombre de usuario no es válido.")
return false
}

/* Si la dirección IP es válida */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
//alert("IP de destino inválida")
return false
}
}
return true
}

}


