Validation part of PHP code I've removed probably needs to be ported to JavaScript code.