Fix #1454 and #1549

Fixes the validator after refreshing captcha/question.
https://github.com/mybb/mybb/issues/1549

Fixes `generate_question()` not considering old question which resulted
in failed refresh sometimes.
https://github.com/mybb/mybb/issues/1549

Cleans JS a bit.