ValidatePostcode
 

ValidatePostcode

Definition

ValidatePostcodeResult ValidatePostcode ( string username, string password, AddressCaptureLicence licence, string postcode ) ValidatePostcodeResult { bool IsValid, string Formatted }

Description:

Checks if a postcode is syntactically valid, and returns the same postcode in a standard format suitable for printing as part of an address.

This method does not check whether an address actually exists at the postcode, only that the postcode is of the correct format.

If the postcode has a correct format, the IsValid part of the result is set to true and the Formatted part of the result is set to the same postcode in a standard format, e.g. "ch652hq" is converted to "CH65 2HQ".

If the postcode does not have a correct format, the IsValid part of the result is set to false and the Formatted part of the result will not be specified.

View all Postcode Lookup Methods

Code Samples

Language:

<!-- Import the Integr8 Ajax API -->
<!-- NOTE: Get your own API key to use in the following script tag from: -->
<!-- http://www.data-8.co.uk/integr8/Admin/Ajax.aspx -->
<script src="http://webservices.data-8.co.uk/Javascript/Loader.ashx?key=your-api-key" type="text/javascript">
</script>

<script type="text/javascript">

function loadIntegr8() {
  // Load the AddressCapture Integr8 service
  data8.load('AddressCapture');
}

function ValidatePostcode(licence, postcode) {
  /// <param name="licence">string. One of the following values: WebServerFull, WebClickFull, WebClickThoroughfare, InternalUserFull, InternalUserThoroughfare, SmallUserFull, Lookup, InternalServerFull, InternalServerThoroughfare, FreeTrial, FreeTrialThoroughfare</param>
  /// <param name="postcode">string</param>
  var addresscapture = new data8.addresscapture();
  
  addresscapture.validatepostcode(
    licence,
    postcode,
    null,
    showValidatePostcodeResult
  );
}

function showValidatePostcodeResult(result) {
  // Check that the call succeeded, and show the error message if there was a problem.
  if (!result.Status.Success) {
    alert('Error: ' + result.Status.ErrorMessage);
  }
  else {
    // TODO: Process method results here.
    // Results can be extracted from the following fields:
    // result.IsValid
    //   Indicates if the postcode is valid or not.
    // result.Formatted
    //   Contains a correctly formatted version of the supplied postcode.
  }
}

loadIntegr8();

</script>
Skip Navigation Links
Request handled by server S2 for client 38.107.191.84 at 21/03/2010 14:23:22