﻿var tletraonumero       = /^([a-z]|\d|[.\-_@])+$/
var tmail               = /^.+\@.+\..+$/
var tnum 				= /^[6-9]+([0-9]{8})+$/
var cpost 				= /^([0-9]{5})+$/
var a					= 0
function Valida(theForm)
{ /*
if (theForm.refidprovincia.value == 0) {
      alert("Seleccione Provincia");
      theForm.refidprovincia.focus();
      return (false);
}
if (theForm.localidad.value == 0) {
      alert("Seleccione Localidad");
      theForm.localidad.focus();
      return (false);
}
if (theForm.RefIdTipoLocal.value == 0) {
      alert("Seleccione tipo");
      theForm.RefIdTipoLocal.focus();
      return (false);
}
 
if (theForm.RefidTipodecocina !== undefined) {
if (theForm.RefidTipodecocina.value == 0) {
      alert("Seleccione tipo");
      theForm.RefidTipodecocina.focus();
      return (false);
}}
if (theForm.RefIdPrecio !== undefined) {
if (theForm.RefIdPrecio.value == 0) {
      alert("Seleccione precio o categoria");
      theForm.RefIdPrecio.focus();
      return (false);
}}nombreconcesi
*/
if (theForm.nombreconcesi !== undefined) {
if (theForm.nombreconcesi.value.length < 3) {
      alert("el campo nombre Concesionario es obligatorio (3 caracteres mínimo");
      theForm.nombreconcesi.focus();
      return (false);
}}
if (theForm.nombre !== undefined) {
if (theForm.nombre.value.length < 3) {
      alert("el campo nombre es obligatorio (3 caracteres mínimo");
      theForm.nombre.focus();
      return (false);
}}

if (theForm.apellidos !== undefined) {
if (theForm.apellidos.value.length < 3) {
      alert("el campo apellidos es obligatorio (3 caracteres mínimo");
      theForm.apellidos.focus();
      return (false);
}}
if (theForm.direccion !== undefined) {
if (theForm.direccion.value.length < 5) {
      alert("el campo direccion es obligatorio (5 caracteres mínimo");
      theForm.direccion.focus();
      return (false);
}}
if (theForm.localidad !== undefined) {
if (theForm.localidad.value.length < 3) {
      alert("el campo localidad es obligatorio (3 caracteres mínimo");
      theForm.localidad.focus();
      return (false);
}}
if (theForm.provincia !== undefined) {
if (theForm.provincia.value == '--') {
      alert("Seleccione provincia");
      theForm.provincia.focus();
      return (false);
}}
if (theForm.marca !== undefined) {
if (theForm.marca.value == '--') {
      alert("Seleccione marca");
      theForm.marca.focus();
      return (false);
}}

if (theForm.Codigopostal !== undefined) {
if (!cpost.test(theForm.Codigopostal.value)) {
      alert("El código postal es obligatorio");
      theForm.Codigopostal.focus();
      return (false);
}}
if (theForm.telefono !== undefined) {
if (!tnum.test(theForm.telefono.value)) {
      alert("Solo son validos numeros españoles");
      theForm.telefono.focus();
      return (false);
}}
if (theForm.movil !== undefined) {
if (!tnum.test(theForm.movil.value)) {
      alert("Solo son validos numeros españoles");
      theForm.movil.focus();
      return (false);
}}
if (theForm.mail !== undefined){
  if (theForm.mail.value=="") 
	{alert("La direccion de correo electronico es obligatoria.");
      theForm.mail.focus();
      return (false); }
    if (!tletraonumero.test(theForm.mail.value)) {
      alert("El campo no puede contener caracteres especiales y solo en minuscula.");
      theForm.mail.focus();
      return (false);}
    if (!tmail.test(theForm.mail.value)) {
      alert("El formato de direccion de correo electronico es:\n[usuario]@[servidor].[dominio]");
      theForm.mail.focus();
      return (false);} }
	  
	if (theForm.mail2 !== undefined){
	if (theForm.mail.value != theForm.mail2.value)
  {alert("Email erroneo");
    theForm.mail.select();
    theForm.mail.focus();
    return (false);} }
if (theForm.fuente !== undefined){
 if (theForm.fuente.value == '') {
      alert("Seleccione opción");
      theForm.fuente.focus();
      return (false);
}}
if (theForm.plazocompra !== undefined){
 if (theForm.plazocompra.value == '--') {
      alert("Seleccione plazo de compra");
      theForm.plazocompra.focus();
      return (false);
}}
if (theForm.okis !== undefined){
 if (theForm.okis.checked != true)
  { alert("Es necesario leer y aceptar los terminos para registrarse");
    theForm.okis.focus();
    return (false);}}

  return (true);
}
