62 lines
2.2 KiB
JavaScript
62 lines
2.2 KiB
JavaScript
|
|
function echeck(str) {
|
|||
|
|
var at="@"
|
|||
|
|
var dot="."
|
|||
|
|
var lat=str.indexOf(at)
|
|||
|
|
var lstr=str.length
|
|||
|
|
var ldot=str.indexOf(dot)
|
|||
|
|
if (str.indexOf(at)==-1) return false
|
|||
|
|
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false
|
|||
|
|
if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false
|
|||
|
|
if (str.indexOf(at,(lat+1))!=-1) return false
|
|||
|
|
if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false
|
|||
|
|
if (str.indexOf(dot,(lat+2))==-1) return false
|
|||
|
|
if (str.indexOf(" ")!=-1)return false
|
|||
|
|
return true
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function ValidateForm(){
|
|||
|
|
if ((document.form1.nombre.value==null)||(document.form1.nombre.value=="")){
|
|||
|
|
alert("Por favor rellene su nombre de contacto")
|
|||
|
|
document.form1.nombre.focus()
|
|||
|
|
return false
|
|||
|
|
}
|
|||
|
|
if ((document.form1.email.value==null)||(document.form1.email.value=="")){
|
|||
|
|
alert("Por favor rellene su email de contacto")
|
|||
|
|
document.form1.email.focus()
|
|||
|
|
return false
|
|||
|
|
}
|
|||
|
|
if ((document.form1.telefono.value==null)||(document.form1.telefono.value=="")){
|
|||
|
|
alert("Por favor rellene su tel<65>fono de contacto")
|
|||
|
|
document.form1.telefono.focus()
|
|||
|
|
return false
|
|||
|
|
}
|
|||
|
|
if ((document.form1.personas.value==null)||(document.form1.personas.value=="")){
|
|||
|
|
alert("Por favor rellene el n<>mero de personas")
|
|||
|
|
document.form1.personas.focus()
|
|||
|
|
return false
|
|||
|
|
}
|
|||
|
|
if ((document.form1.habitaciones.value==null)||(document.form1.habitaciones.value=="")){
|
|||
|
|
alert("Por favor rellene el n<>mero de habitaciones")
|
|||
|
|
document.form1.habitaciones.focus()
|
|||
|
|
return false
|
|||
|
|
}
|
|||
|
|
if ((document.form1.entrada.value==null)||(document.form1.entrada.value=="")){
|
|||
|
|
alert("Por favor rellene la fecha de entrada")
|
|||
|
|
document.form1.entrada.focus()
|
|||
|
|
return false
|
|||
|
|
}
|
|||
|
|
if ((document.form1.salida.value==null)||(document.form1.salida.value=="")){
|
|||
|
|
alert("Por favor rellene la fecha de salida")
|
|||
|
|
document.form1.salida.focus()
|
|||
|
|
return false
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (echeck(document.form1.email.value)==false){
|
|||
|
|
alert("Email de contacto incorrecto, por favor, rev<65>selo")
|
|||
|
|
document.form1.email.focus()
|
|||
|
|
return false
|
|||
|
|
}
|
|||
|
|
return true
|
|||
|
|
}
|
|||
|
|
|