Skip to content

Instantly share code, notes, and snippets.

@BrettBailey
Created June 1, 2015 23:25
Show Gist options
  • Save BrettBailey/2b3c1977e5fad90d8596 to your computer and use it in GitHub Desktop.
Save BrettBailey/2b3c1977e5fad90d8596 to your computer and use it in GitHub Desktop.
Formats a validated postcode by upper-casing and restoring the space if needed
$scope.formatPostcode = function() {
var postcode = $scope.complaint.postcode.toUpperCase(),
index = postcode.length - 3;
if (postcode.charAt(index - 1) == " ") return;
return $scope.complaint.postcode = postcode.substr(0, index) + ' ' + postcode.substr(index);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment