Update script.js

Added validation.