update validate function
format demo code for index page