Posted By

nicolaspar on 08/02/06


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


Javascript - Validación básica

 / Published in: PHP

Se incluye la funcion trim() agregada a completo y emailvalido.

  1. errColor='#F7F7F7';
  2. function trim(str){return str.replace(/^\\s*|\\s*$/g,'');}
  3. function completo(obj,nombre,tipo){if (tipo=='int'){ if ((trim(obj.value)=='')||(isNaN(obj.value))){;return '\\n* '+nombre+' '}else{return '';};}else{ if (trim(obj.value)==''){;return '\\n* '+nombre+'.'}else{return ''}}}
  4. function emailvalido(obj,nombre) {msg = '';if(obj.value!=''){var reg1 = /(@.*@)|(\\.\\.)|(@\\.)|(\\[email protected])|(^\\.)/;var reg2 = /^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$/;if (reg1.test(obj.value) || !reg2.test(obj.value)){;msg= '\\n* '+nombre+'.'}}else{; msg='\\n* '+nombre+'.'} return msg}

Report this snippet  

You need to login to post a comment.