w3Utils Reference

Reference


w3 ValidationUtils

 w3.ValidationUtils
    CheckEmailAddress( EmailAddress, [DeepScan] ) : Boolean
    CheckSumMod10( Number ) : Byte
    GetCreditcardType( CCNumber ) : String
    SE_CheckBankgironr( szBGNR ) : Boolean
    SE_CheckOrgnr( szOrgNr ) : Boolean
    SE_CheckPostgironr( szPGNr ) : Boolean
    SE_CheckPsnr( szPSNR ) : Boolean


Methods

  CheckEmailAddress(EmailAddress, [DeepScan]) : 
Checks to see if an email address is valid.

If DeepScan is set to true, it actually checks if the user is valid in the specified domain.

The Deepscan function is dependent on the SMTP server of the domain as this function asks the server to validate the email address. Deepscan works in several stages:

1. Basic check as in using funtion w/o Deepscan (checks address syntax - aaa@xxx.yyy)
2. Then Deepscan goes on to check the domain name - is the domain valid? If so...
3. Deepscan searches for a SMTP mail server of the domain.

If this argument is not set, but Deepscan is enabled (set to true) it stops at step three and returns true if a mail server is found.

Please note that Deepscan consumes resources and does take quite som time to complete, this is important when (and if) you decide to use it.

Note also that Deepscan is dependent on the mailserver with which it is communicating when validating an adress. There are so many variables in how mailservers are configured and connected to the Internet that incorrect results may be obtained. In other words, Deepscan is not foolproof.

// *** A. Simple check ( step 1 only ):

mailOk = validationUtils.CheckEmailAddress( 'support@dimac.net' );
// checks to see that the address 'looks ok'. 
// Returns true if so.


// *** B. Deepscan enabled ( step 1-3 )

mailOk = validationUtils.CheckEmailAddress( 'support@dimac.net', true );

// checks to see that the address 'looks ok', that the 'dimac.net' domain is 
// valid and that the domain has a mail server. 
// Returns true if all of those checks return positive results
  CheckSumMod10(Number) : 
Method used by several of the other methods in the package.
var checkSum = ValidationUtils.CheckSumMod10( aNumber );
  GetCreditcardType(CCNumber) : 
Given a string, returns the type of creditcard.

Supports: VISA, Mastercard, AmEx.
var cardNo = Request.Form( 'creditCard' ).item;

var cardType = ValidationUtils.GetCreditcardType( cardNo );

if( cardType == 'VISA' ) 
{ 
	alert( 'This is a VISA card' );
}
  SE_CheckBankgironr(szBGNR) : 
Checks a swedish 'bankgiro' number
var accNo = Request.Form ( 'accNumber' ).item;

if ( !ValidationIUtils.SE_CheckBankGironr( accNo ) )
{
	errMsg = 'The entered account number is not valid!';
	ok = 0;
}
  SE_CheckOrgnr(szOrgNr) : 
Checks a swedish organisation number
var orgNo = Request.Form ( 'orgNumber' ).item;

if ( !ValidationIUtils.SE_CheckOrgnr( orgNo ) )
{
	errMsg = 'The entered organisation number is not valid!';
	ok = 0;
}
  SE_CheckPostgironr(szPGNr) : 
Checks a swedish postal giro account number
var accNo = Request.Form ( 'accNumber' ).item;

if ( !ValidationIUtils.SE_CheckPostGironr( accNo ) )
{
	errMsg = 'The entered account number is not valid!';
	ok = 0;
}
  SE_CheckPsnr(szPSNR) : 
Checks the given swedish personal number

Is similar to the US Social Security number
var persNo = Request.Form ( 'personalNumber' ).item;

if ( !ValidationIUtils.SE_CheckPsnr( persNo ) )
{
	errMsg = 'The entered personal number is not valid!';
	ok = 0;
}