Since you are validating a value from the recordset, you will have to manually move the validation code below the recordset.
So take the code on lines: 9-23 and move it below the recordsets... probably just above the doctype tag.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.