Did you try this as a custom format script instead of a validation script?
If you try to do this as a validation script, event.value doesn't appear to be valid- which is weird, because there's no reason it shouldn't be. On the other hand, this works as a custom format script. If it were a validation script, you wouldn't need any line past the first- since it's not, you need to manage the formatting of the text since your format type is set as Custom, and that's what the last two lines manage.