fixes #5518 blank spaces must not affect unique fields

Fixed the issue and pushed the code for review, please check it.