Jump to content


Photo

Registration form validation


  • Please log in to reply
2 replies to this topic

#1 ColinDoody

ColinDoody
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 21 April 2006 - 04:12 AM

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.

#2 KrisNz

KrisNz
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts
  • LocationAuckland, New Zealand

Posted 21 April 2006 - 04:23 AM

[!--quoteo(post=367092:date=Apr 21 2006, 02:12 PM:name=ColinDoody)--][div class=\'quotetop\']QUOTE(ColinDoody @ Apr 21 2006, 02:12 PM) View Post[/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.

#3 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 21 April 2006 - 10:01 AM

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.
Think you're smarty?

(Gone until 20 to November)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users