Jump to content

Registration form validation


ColinDoody

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.
Link to comment
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.
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.