Jump to content

Archived

This topic is now archived and is closed to further replies.

ColinDoody

Registration form validation

Recommended Posts

Hey everyone. I appreciate the help.

So I am developing a prototype site for a company and I am doing user registration at this point. User enters an email address, password, some other checkboxes and the like that are linked up with an sql database. On submit, the page calls itself and sends data usually through the post method defined on the form tag.

Problem is, I think Id really like to do simple validation steps before the form gets sent. So, for example, Id like to make sure fields are filled in before the submit is made. So that can be accomplished through javascript quite easily correct?

My issue is that by calling a javascript function I then replace the POST method, correct? And if I am replacing the POST method, I dont believe my POST data will be available when I recall the page.

So how could i do this? I dont want to set the variables through GET because there is a password involved. Is there any way that in javascript i can force the variables into the POST slots?

Thank you. I hope that made sense. I can be quite a n00b sometimes.

Share this post


Link to post
Share on other sites
[!--quoteo(post=367092:date=Apr 21 2006, 02:12 PM:name=ColinDoody)--][div class=\'quotetop\']QUOTE(ColinDoody @ Apr 21 2006, 02:12 PM) [snapback]367092[/snapback][/div][div class=\'quotemain\'][!--quotec--]
My issue is that by calling a javascript function I then replace the POST method, correct? And if I am replacing the POST method, I dont believe my POST data will be available when I recall the page.

So how could i do this? I dont want to set the variables through GET because there is a password involved. Is there any way that in javascript i can force the variables into the POST slots?

Thank you. I hope that made sense. I can be quite a n00b sometimes.
[/quote]

No, validating with javascript wont stop you posting your form to the server. Validating with js can be good as it saves your user a round trip to the server only to find out they've missed a field but its not fullproof as javascript can be turned off, so you'll at least want to perform the same validations with your php code as you do with javascript.

Share this post


Link to post
Share on other sites
Like KrisNZ said, you can have JS validation and the POST method in the same time, but JS is not a good for validating forms. If you want to have JS validation you have to create a function that validates the form and add in the body tag <body... onsubmit="YourFunction()">.
But you simply use php for that, with the empty function, isset function, is_numric etc'.

Orio.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.