Visualizzazione dei risultati da 1 a 2 su 2

Discussione: [AS] check Mail in AS

  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2004
    Messaggi
    170

    [AS] check Mail in AS

    Ciao a tutti!
    Vorrei chiedervi se è possibile fare un check mail in actionscript ... esiste una sorta di utilizzo di espressioni regolari o altro??
    grazie mille per ogni eventuale risposta
    Ariok

  2. #2
    Utente di HTML.it
    Registrato dal
    Mar 2004
    Messaggi
    170
    Ho trovato questa funzione nel caso qualcuno cercasse l'argomento sul forum...
    Devo ancora leggere per bene come si comporta... ho qualche dubbio sul corretto funzionamento della funzione checkfirstLevelDomainChars... vedo un "J" sospetto in s.charAt(j)... però ripeto devo controllarla ancora bene..
    Ciao a tutti..

    codice:
    function checkEmail (e) {
    	var i, j, l = e.length;
    	var foundPoint = false;
    
    	function checkChars (s, i, l) {
    		while (i < l && ("_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789").indexOf(s.charAt(i)) != -1){
    			i++;
    		}
    		return i;
    	}
    	function checkFirstLevelDomainChars (s, i, l) {
    		while (i < l && ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").indexOf(s.charAt(j)) != -1) {
    			i++;
    		}
    		return (i == l);
    	}
    	trace(e);
    
    	// every email starts with a string
    	if ((i=checkChars(e, 0, l)) == 0) {
    		return -1;
    	}
    	//init j
    	j=i;
    
    	// followed by an arbitrary number of ("." string) combinations
    	while (i < l && e.charAt(i) == ".") {
    		// skip the point
    		i++;
    		// if there are no chars, we have an error
    		if ((j=checkChars(e, i, l)) == i) {
    			return -2;
    		}
    		// else skip the chars
    		i = j;
    	}
    	// then follows the magic @
    	if (e.charAt(i) != "@"){
    		return -3;
    	}
    
    	// followed by minimum one string point string
    	// after the last point minimum 2 characters are allowed
    
    	do {
    		// skip the @ (j == i at the beginning, so it is like i++)
    		i = j+1;
    		// do we have more chars ?
    		j = checkChars(e, i, l);
    		if (j == i) {
    			// no more chars found -> error
    			return -4;
    		} else if (j == e.length) {
    			// emailaddress is finished, do we have a first level domain ?
    			j -= i;
    			// we have one if it is at least 2 long and consists of the correct characters
    			if(foundPoint && j>=2 && checkFirstLevelDomainChars(e, i, l)){
    				return 1
    			} else {
    				return -5
    			}
    		}
    		// if we reach the end or don't have a point, we return an error
    		foundPoint = (e.charAt(j) == ".");
    	} while (i < l && foundPoint);
    	return -6;
    }
    Ariok

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.