ColinDoody Posted April 21, 2006 Share Posted April 21, 2006 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. Quote Link to comment Share on other sites More sharing options...
KrisNz Posted April 21, 2006 Share Posted April 21, 2006 [!--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. Quote Link to comment Share on other sites More sharing options...
Orio Posted April 21, 2006 Share Posted April 21, 2006 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.