Can a PHP Form Vaildation Work along Side a Standard Form Vaildation
Hello Everbody, My names andy and am a newby here, with some Knowledge to Web design..But not a Pro. by far not.
I have a website am working on, that will advertise a hoilday Let...
The contact forms are done in PHP and is Vaildated and asks for items like Name , email, address, and so on. On the same page is the jquery Datepicker and it to is Vaildated with this call to script <script src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>.
The problem am facing is, I can not make these too Vaildation work together on the same page.
When the PHP fields for the Name and Email are filled in, you then select the dates you want from the datepicker,, then you press Submit, and the form is Submitted if all field are Right. and thats what i want.
But the snag is if you dont select any date from the picker and press submit,, it will send with empty fields from the picker and not pick up on the empty form.
Both these codes work great on there own, but joint them together on one page one underneath each other and the PHP takes control and the script does not run the Vaildation for the picker. The picker does work if you do input the date, it will email all the forms. Oh and there is just one submit button.
If by standard form validation you mean browser-side (client-side, usually Javascript) validation then this can definitely co-exist with server-side PHP validation. The browser-side validation is called first (with Javascript) and then the form data is sent to be processed by PHP on the server side (assuming is is valid, generally a failed browser-side validation will halt the sending of the form to the server).
It sounds to me as if you want to stop a form with empty fields being posted to the server - browser-side validation with Javascript would work, if you want an instant notification to the user that they must fill in the form before submitting.
However you should never rely on Javascript validation alone, a user can simply disable Javascript and bypass it. Your PHP needs to have a way of dealing with empty form fields, and should never assume that validation will have occurred beforehand with Javascript.
Therefore my suggestion would be for you to program your PHP script to handle empty fields in some way - redisplay the form with error messages for instance - and once that's working, add additional Javascript validation to complement the DatePicker validation.
Hopefully I've understood what you're trying to say, posting the code you're using would be helpful!
The validation of the form that you require has to be done on the server as that's the only place where you have control of whether it runs or not.
Any JavaScript validation is there for the convenience of the person filling out the form. It tells them about errors straight away rather than them filling out the whole form and submitting it and then being told that they entered everything wrong (as will still happen for the small percentage who don't have JavaScript but there's nothing you can do to provide faster feedback for them).
Yes the Php code all works and vaildates the form field and so does the datepicker's form that all works too. the problem lie when i place them together on the page only the php would work then. what am going to do is to post my code on here if you could take a look. thanks andy
Bookmarks