update script.js, fixed invalid input bug.