Updated JS

Checked for blank (spacebar) entries with trim
Updated JS

Corrected trim function to check for blank entries