![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
03/03/2006, 12:05
|
| | Fecha de Ingreso: febrero-2006
Mensajes: 142
Antigüedad: 19 años Puntos: 0 | |
por ejemplo esto no sirve en netscape
Código:
function valida()
{
if (document.getElementById('Name').value=="" || document.getElementById('Mailx').value=="" || document.getElementById('Telephone').value=="" ||document.getElementById('Fax').value ==""||document.getElementById('Address').value==""||document.getElementById('Comments').value=="")
{
alert("debes de llenar todos los registros");
}
else
{
var mytex=document.getElementById('Mailx').value;
var mytel=document.getElementById('Telephone').value;
var myfax=document.getElementById('Fax').value;
if (validaMail(mytex))
{
if (isPhoneNumber(mytel))
{
if (isPhoneNumber(myfax))
{
if (document.getElementById("sel").value==0)
{
alert("DEBES ELEGIR UN CONTACTO");
}
if (document.getElementById("sel").value==1)
{
document.getElementById("td_name").innerHTML+='<input type="hidden" name="title" id="title" value="INFORMACION Y PREGUNTAS">';
window.form1.submit();
}
if (document.getElementById("sel").value==2)
{
document.getElementById("td_name").innerHTML+='<input type="hidden" name="title" id="title" value="INFORMACION DE PRODUCTOS">';
window.form1.submit();
}
if (document.getElementById("sel").value==3)
{
document.getElementById("td_name").innerHTML+='<input type="hidden" name="title" id="title" value="VENTAS">';
window.form1.submit();
}
}
else
{
alert("El numero del fax es incorrecto!!")
document.getElementById('Fax').value="";
document.getElementById('Fax').focus()
}
}
else
{
alert("El telefono es incorrecto!!");
document.getElementById('Telephone').value="";
document.getElementById('Telephone').focus()
}
}
}
}
function validaMail(Objeto)
{
var my_val=document.getElementById('Mailx').value;
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(my_val)){
return (true)
} else {
alert("Dirección de e-mail invalida!!");
alert(my_val);
document.getElementById('Mailx').value="";
document.getElementById('Maixl').focus()
return (false);}
}
/*funciones para validar numero de telefono */
var defaultEmptyOK = false
var phoneChars = "()-+ ";
function isPhoneNumber (s)
{ var modString;
if (isEmpty(s))
if (isPhoneNumber.arguments.length == 1) return defaultEmptyOK;
else return (isPhoneNumber.arguments[1] == true);
modString = stripCharsInBag( s, phoneChars );
return (isInteger(modString))
}
function isEmpty(s)
{ return ((s == null) || (s.length == 0))
}
function isInteger (s)
{ var i;
if (isEmpty(s))
if (isInteger.arguments.length == 1) return defaultEmptyOK;
else return (isInteger.arguments[1] == true);
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if( i != 0 ) {
if (!isDigit(c)) return false;
} else {
if (!isDigit(c) && (c != "-") || (c == "+")) return false;
}
}
return true;
}
function stripCharsInBag (s, bag)
{ var i;
var returnString = "";
// Buscar por el string, si el caracter no esta en "bag",
// agregarlo a returnString
for (i = 0; i < s.length; i++)
{ var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}
function isDigit (c)
{ return ((c >= "0") && (c <= "9"))
}
function show(val)
{
if (val==0)
{
document.getElementById("div_f").style.display='none';
}
else
{
document.getElementById("div_f").style.display='block';
}
}
function sel_body(tem)
{
if(tem==1)
{
document.getElementById("td_u").innerHTML+='<input type="hidden" name="bodysel" id="title" value="1">';
window.fm.submit();
}
if(tem==2)
{
document.getElementById("td_u").innerHTML+='<input type="hidden" name="bodysel" id="title" value="2">';
window.fm.submit();
}
if(tem==3)
{
document.getElementById("td_u").innerHTML+='<input type="hidden" name="bodysel" id="title" value="3">';
window.fm.submit();
}
}
function sel()
{
alert('hola');
}
function insert_u()
{
if (document.getElementById("name").value=="" && document.getElementById("user").value==""&&document.getElementById("status").value==2)
{
alert("debes llenar al menos un registro entre Nombre,Nickname o Staus");
}
else
{
document.getElementById("td_in").innerHTML+='<input type="hidden" name=action value="2">';
window.f_user.submit();
}
}
Última edición por ever_diaz8; 03/03/2006 a las 12:13 |