Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    verifica inserimento indirizzo mail o @ nel form

    Ciao a tutti, sto usando per le prime volte ASP e ho bisogno di due consigli:

    IL FORM QUI SOTTO VERIFICA CHE L'UTENTE COMPILI IL CAMPO E-MAIL ALTRIMENTI DA UN MESSAGGIO DI ERRORE, MA OLTRE A CIO' A ME SERVIREBBE CHE FOSSE IN GRADO DI VERIFICARE CHE CIO' CHE VIENE INSERITO SIA PROPRIO UN 'E-MAIL E NIENTE ALTRO, PER ESEMPIO ACCERTANDOSI DELLA PRESENZA DI "@"

    <td height="74" align="center"> <%
    Set Mailer = Server.CreateObject("SMTPsvg.Mailer")

    rem cambia questo indirizzo con un valido indirizzo SMTP del tipo mail.nomediminio
    Mailer.RemoteHost = "127.0.0.1"
    Mailer.FromAddress = Request.QueryString("addressfrom")
    Mailer.AddRecipient "Nome destinatario","info@arkaline.com"
    Mailer.Subject = "Soggetto email"

    if not Mailer.SendMail then
    Response.Write "errore! Inserisci nuovamente il tuo indirizzo e-mail"
    else
    Response.Write "grazie per esservi iscritti"
    end if
    %>


    CHE SI PUO' FARE?
    INOLTRE I MESSAGGI CREATI DA QUESTO ASP SI POSSONO FORMATTARE IN MODI DIVERSI SOLO ATTRAVERSO CSS?
    MA DOVE SI INSERISCE IL CODICE NEL ASP?

    SPERO DI ESSERE STATO CHIARO

    GRAZIE

  2. #2
    questa l'ho fatta io e funziona alla perfezione.
    basta che metti emailaddresstest(indirizzoemail) per fare il controllo. se ti ritorna true è valida altrimenti no.

    codice:
    'controllo validità e-mail
    function emailaddresstest(emailaddr)
       dim ava, charcode, domain, localpart, subdomain, subdomains, tld
    
       'check for valid syntax in an email address
       emailaddresstest=true
    
       'parse out the local part and the domain
       ava=instrrev(emailaddr,"@")
       if ava <= 1 then
          emailaddresstest=false
          exit function
       end if
       localpart=left(emailaddr,ava-1)
       domain=mid(emailaddr,ava+1)
       if len(localpart) < 1 or len(domain) < 3 then
          emailaddresstest=false
          exit function
       end if
    
       'check for invalid characters in the local part
       for ava=1 to len(localpart)
          charcode=asc(mid(localpart,ava,1))
          if charcode < 32 or charcode >= 127 then
    	 emailaddresstest=false
    	 exit function
          end if
       next
    
       'check for invalid characters in the domain
       domain=lcase(domain)
       for ava=1 to len(domain)
          charcode=asc(mid(domain,ava,1))
          if not ((charcode >= 97 and charcode <= 122) or (charcode >= 48 and charcode <= 57) or charcode=45 or charcode=46) then
    	 emailaddresstest=false
    	 exit function
          end if
       next
    
       'check each subdomain
       subdomains=split(domain,".")
       for each subdomain in subdomains
          if len(subdomain) < 1 then
    	 emailaddresstest=false
    	 exit function
          end if
       next
    
       'last subdomain should be a TDL
       tld=subdomains(ubound(subdomains))
       if not isarray(validtlds) then
          call setvalidtlds()
       end if
       for ava=lbound(validtlds) to ubound(validtlds)
          if tld=validtlds(ava) then
    	 exit function
          end if
       next
       emailaddresstest=false
    end function
    
    sub setvalidtlds()
    
         'load the global list of valid TLDs
         validtlds=array("ac", "ad", "ae", "aero", "af", "ag", "ai", "al", _
          "am", "an", "ao", "aq", "ar", "as", "at", "au", "aw", "az", "ba", _
          "bb", "bd", "be", "bf", "bg", "bh", "bi", "biz", "bj", "bm", "bn", _
          "bo", "br", "bs", "bt", "bv", "bw", "by", "bz", "ca", "cc", "cd", _
          "cf", "cg", "ch", "ci", "ck", "cl", "cm", "cn", "co", "com", _
          "coop", "cr", "cu", "cv", "cx", "cy", "cz", "de", "dj", "dk", _
          "dm", "do", "dz", "ec", "edu", "ee", "eg", "eh", "er", "es", "et", _
          "fi", "fj", "fk", "fm", "fo", "fr", "ga", "gd", "ge", "gf", "gg", _
          "gh", "gi", "gl", "gm", "gn", "gov", "gp", "gq", "gr", "gs", "gt", _
          "gu", "gw", "gy", "hk", "hm", "hn", "hr", "ht", "hu", "id", "ie", _
          "il", "im", "in", "info", "int", "io", "iq", "ir", "is", "it", _
          "je", "jm", "jo", "jp", "ke", "kg", "kh", "ki", "km", "kn", "kp", _
          "kr", "kw", "ky", "kz", "la", "lb", "lc", "li", "lk", "lr", "ls", _
          "lt", "lu", "lv", "ly", "ma", "mc", "md", "mg", "mh", "mil", "mk", _
          "ml", "mm", "mn", "mo", "mp", "mq", "mr", "ms", "mt", "mu", _
          "museum", "mv", "mw ", "mx", "my", "mz", "na", "name", "nc", "ne", _
          "net", "nf", "ng", "ni", "nl", "no", "np", "nr", "nu", "nz", "om", _
          "org", "pa", "pe", "pf", "pg", "ph", "pk", "pl", "pm", "pn", "pr", _
          "pro", "ps", "pt", "pw", "py", "qa", "re", "ro", "ru", "rw", "sa", _
          "sb", "sc", "sd", "se", "sg", "sh", "si", "sj", "sk", "sl", "sm", _
          "sn", "so", "sr", "st", "sv", "sy", "sz", "tc", "td", "tf", "tg", _
          "th", "tj", "tk", "tm", "tn", "to", "tp", "tr", "tt", "tv", "tw", _
          "tz", "ua", "ug", "uk", "um", "us", "uy", "uz", "va", "vc", "ve", _
          "vg", "vi", "vn", "vu", "wf", "ws", "ye", "yt", "yu", "za", "zm", _
          "zw")
    end sub
    Matrix è ovunque, è intorno a noi, anche adesso nella stanza in cui siamo. È quello che vedi quando ti affacci alla finestra o quando accendi il televisore. L'avverti quando vai al lavoro, quando vai in chiesa, quando paghi le tasse. È il mondo che ti è stato messo dinanzi agli occhi, per nasconderti la verità.

  3. #3
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Please non scrivere in maiuscolo!
    Ecco uan funzioncina per verificare che quello che è stato inserito nel form sia sintatticamente una email:

    codice:
    <%
    'Verifica della correttezza di una email
    function check_email(strng)
    	'Creazione della Regular Expression 
    	Set regEx = New RegExp
    
    	'Definizione del pattern di validazione
    	regEx.Pattern = "^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,4}$"
    
    	'Ignoro maiuscole e minuscole nell'indirizzo email
    	regEx.IgnoreCase = True
    	
    	'TRUE se l'email è valida
    	check_email = regEx.Test(strng)
    end function
    %>
    Roby

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.