开发者

Twitter style validation in homepage to sign up

I've got a Rails app right now that has a form on the homepage for sign up. It's a nested model form that creates both user and profile. When sign up is clicked, the newly created user is taken to Profiles#edit to fill in their profile. This annoys me because I wanted to use Profiles#edit in my User's settings. So I'd like to do what Twitter does to try and bypass this.

Specifically, what I'd like to do is add a similar validation process that occurs between twitter.com and twitter.com/signup. On twitter.com, the User enters their information, then clicks sign up. You're taken to twitter.com/signup with in-line validation showing whether the Full name, email, and password are valid. (I imagine this is using some form of jQuery/JavaScript because it doesn't create the user.) The user then fills out the rest of the form, agrees to terms, and joins. This开发者_开发百科 creates the user and User profile.

Can anyone suggest how this might be done? Particularly with a nested model form like mine. I'm new to programming but would appreciate any help in helping me re-create this.


This is how I would approach the problem from a structuring standpoint.

On the front page, with the sign up...you just need a standard form that you can submit to your server. Your server should then do the name/email/password validation and the response should redirect the browser to the signup page, with the information from the validation (which fields pass/fail).

Now that you are on the sign up page, when the user tries to sign up, you would send an AJAX request to your server for the name/email/username/password verification. If it checks out, then register the user, log them in, and then send the redirect response to the user's home page or profile page, or whatever they should see when logging in. If this validation fails, then you would return the error information and then display it on the page.

Hope this helps you get started.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜