Created
June 1, 2015 23:25
-
-
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
This file contains hidden or 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
$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