Free Webmaster Resources .info
PHP Introduction and Tutorials Javascript  Introduction and Tutorials HTML  Introduction and Tutorials ASP  Introduction and Tutorials Free Internet Access Guide and Directory Webspace  Directory Webhosting  Directory Adult Webhosting  Directory PHP Hosting  Directory ASP Hosting  Directory
à Navigation
» Home
» What is ASP?
» ASP Library
» Free ASP Hosting
» Submit Scripts
 
Subscribe for free!

Join our mailing list today and recieve free updates monthly with web hosting specials!
 
 

 

 

Free Webmaster Resources .info | ASP Library


3 Common String Functions

Filename: string_functions.asp
Use: 3 Common string handling function: check for valid email address, check for alpha-numeric, strip special characters. Written by Jay McVinney.

<%
'-------------------------------------------------------------------------------------
'-- Check for valid email address

Function IsEmail(sCheckEmail)
  Dim sEmail, nAtLoc
  IsEmail = True
  sEmail = Trim(sCheckEmail)
  nAtLoc = InStr(1, sEmail, "@") 'Location of "@"

  If Not (nAtLoc > 1 And (InStrRev(sEmail, ".") > nAtLoc + 1)) Then
     &'"@" must exist, and last "." in string must follow the "@"
     &IsEmail = False
  ElseIf InStr(nAtLoc + 1, sEmail, "@") > nAtLoc Then
     &'String can't have more than one "@"
     &IsEmail = False
  ElseIf Mid(sEmail, nAtLoc + 1, 1) = "." Then
     &'String can't have "." immediately following "@"
     &IsEmail = False
  ElseIf InStr(1, Right(sEmail, 2), ".") > 0 Then
     &'String must have at least a two-character top-level domain.
     &IsEmail = False
  End If
End Function

'-- USAGE
'-- IsEmail("whoeverr@domain") Returns False
'-- IsEmail("who.ever@domain") Returns False
'-- IsEmail("www.askasp.com") Returns False
'-- IsEmail("whoever@domain@net") Returns False
'-- IsEmail("whoever@.domain.net") Returns False
'-- IsEmail("whoever@domain.n") Returns False
'-- IsEmail("whoever@domain.net") Returns True
%>

<%
'-------------------------------------------------------------------------------------
'-- Check for special symbols

Function IsAlphaNumeric(sString)
  Dim nChar, i
  IsAlphaNumeric = True
  For i = 1 To Len(sString)
    nChar = Asc(LCase(Mid(sString, i, 1)))
    If not ((nChar > 47 And nChar < 58) or (nChar > 96 And nChar < 123) or nChar = 32) Then
      IsAlphaNumeric = False
      Exit For
    End If
  Next
End Function

'-- USAGE:
'-- IsAlphaNumeric("1273 Lovers Lane #B") Returns False
'-- IsAlphaNumeric("1273 B Lovers Lane") Returns True
'-- IsAlphaNumeric("1273 B. Lovers Ln.") Returns False
'-- IsAlphaNumeric("1273 B Lovers Ln") Returns True
%>

<%
'-------------------------------------------------------------------------------------
'-- Strip special symbols

Function StripSymbols(sString)
  Dim nCharPos, sOut, nChar
  nCharPos = 1
  sOut = ""
  For nCharPos = 1 To Len(sString)
    nChar = Asc(Lcase(Mid(sString, nCharPos, 1)))
    If ((nChar > 47 And nChar < 58) or (nChar > 96 And nChar < 123) or nChar = 32) Then
      sOut = sOut & Mid(sString, nCharPos, 1)
    End If
  Next
  StripSymbols = sOut
End Function

'-- USAGE:
'-- StripSymbols("1273 B. Lovers Ln.") 'Returns "1271 B Maiden Ln"
'-- StripSymbols("1273 Lovers Lane #B") 'Returns "1271 Maiden Lane B"
%>

 


Recommended Webhosting Company
Find free web hosting
Looking for free web hosting? Review and compare FindStuff's comprehensive resources. Search now!

 

 
Related Websites
 


Free Email
Your source to free email.

Free Casino Downloads
Contains useful free casino downloads.

Free Software Downloads
A complete collection of free software downloads.

Free
Download free stuff from psike.com your free stuff resource.

Free Teen Online Dating
Meet other singles for free online dating.

Coolfreeweb.com
The Free category at coolfreeweb.com

My Directory Listing
A massive directory listing of websites

Website Collation Project
The website collation project contains a huge directory of websites.


 
Top Webhosts
 
 1. Find free web hosting
 2. free web hosting Web Ho
 3. Free Web Hosting
 4. Web Hosting
 5. Webhosting
 
-
- Give us feedback
 
Last updated
Nov 19, 2008
Free Webmaster Resources .info | A resource must for every web master
Untitled Document - Web Hosting
- PHP Hosting
- Free Internet Access