Page 1 of 1
form help
Posted: Thu Dec 22, 2005 9:21 pm
by method_man
how can i make it so that on my register page all forms have to have something typed in and all drop down boxes have to select something besides the default?
also how can i make it so it displays a javascript box that says Email Addresses don't match if Email Address and Confirm Email Address dont match? Same thing with password and confirm password
thanks,
matt
Posted: Thu Dec 22, 2005 9:31 pm
by neophyte
Sounds like you need a javascript solution....
In the from tag ad onsubmit="checkForm();"
Then build the function.
Code: Select all
function checkForm(){
if (document.formname.fieldname.value == ""){ ///Check the value of the field
window.alert('some message');
}
}
It would look something like that...
There are lots of toots on the web for stuff like this.
Posted: Thu Dec 22, 2005 9:33 pm
by trukfixer
I dont rely on javascript for that - I post the data to the handler script, (typically posts back to itself) and then check post data for parameters (empty values, dirty data, numbers where you only want letters, etc) and assign errors to an array (or a string) and re-display the form prepopulated with the previously submitted data (and using CSS to highlight in an "alert" color, the fields that gave errors, along with the error messages) whe they get all teh data required submitted (and cleaned somewhat) I assign all data to SESSION data and redirect to the php script that processes the data and does whatever with it, then redirect to whatever "results" page I want to display to them - it's a lot more work that using JavaScript, but if it is mission critical data, it's a heck of a lot more secure (A user can just turn off JavaScript and still submit dirty data or empty data to your form, or post it from another form that doesnt have JavaScript on it, so JavaScript is at best just a "page pretty-upper" - there *are* some uses for Javascript that help enhance security quite well, but none of it does any form input validation

Posted: Thu Dec 22, 2005 9:40 pm
by neophyte
Some one correct me if I'm wrong but if you config your pop-up blocker to block all pop-ups won't some them even block alerts? If that person has turned off their notification too they may never know something was wrong....
Posted: Thu Dec 22, 2005 9:42 pm
by method_man
thanks

Posted: Thu Dec 22, 2005 10:36 pm
by hawleyjr
I've used AJAX validation for this. Works great. OnBlur of each form field send the form values & validate that they are the same and valid. On return set a div tag to display an error or success.
Posted: Thu Dec 22, 2005 10:39 pm
by josh
Or even an onchange, as the users type their email they see a red X, as soon as it detects the emails matching it changes to a green check
Posted: Fri Dec 23, 2005 6:50 pm
by supernerd
Check out Zoopframework
It has integrated form validation using it's guiControls component. It integrates both javascript and php validation and supports required and many different format typing like phone, creditcard, numeric, etc...
GuiControls work using normal posts, or through AJAX.
You can find zoop at
http://zoopframework.com. It has pretty extensive documentation and also has a forum where you can get help.
They even have a movie there to show you the form validation in action.