Last active
June 30, 2022 15:33
-
-
Save mrmascott10/314b7497e1fbe1f72f13d2cc5f373d7e to your computer and use it in GitHub Desktop.
Validate a postcode without using a database.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// **************************************** | |
// Checks if a postcode is valid | |
// **************************************** | |
function postcodeValid(postcode) { | |
var result; | |
$.get( "https://api.postcodes.io/postcodes/" + postcode + "/validate", function(data) { | |
result = data['result']; | |
}); | |
return result; | |
} | |
// **************************************** | |
// **************************************** | |
// * Get details about a postcode | |
// **************************************** | |
function postcodeValid(postcode) { | |
var result; | |
$.get( "https://api.postcodes.io/postcodes/" + postcode, function(data) { | |
result = data; | |
}); | |
return result; | |
} | |
// **************************************** | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment