Question
Mixing javascript & php validation
I have been wrestling with the idea of processing and
validating a page (form) within a single script and I'm still
struggling with it. The source of my problem lies in the code
Dreamweaver creates if you use the 'validate on Submit' behaviour.
The javascript will do some basic validation via a function called MM_validateForm and return the result via 'document.MM_returnValue'.
This function is associated with the 'submit' button (onclick) so I can see how we validate, display errors, and check to see when we come back through the routine, if we've been here before (if (!$_POST['submit']) etc) but I can't see:
i) What is re-displaying the calling routine in the event of an error - i.e. why is the page looping around when an error is found? I guess something in the 'onclick' is somehow interpreting the validity of the page and redirecting back around when there are problems but I can't what is driving this.
ii) How I can expand the javascript routine with my own php code (I'm guessing I can't just add in php code to the function that Dreamweaver has written) to say, verify logon details against the db. If we go back around I can add in some extra code that will be executed on submit but if I get an error in my code, how do I convey that to the 'onclick' to take me back around again - the javascript function is in there already ... D'oh!
Are you with me? ...... is there anybody there ....
Thanks.
P.
The javascript will do some basic validation via a function called MM_validateForm and return the result via 'document.MM_returnValue'.
This function is associated with the 'submit' button (onclick) so I can see how we validate, display errors, and check to see when we come back through the routine, if we've been here before (if (!$_POST['submit']) etc) but I can't see:
i) What is re-displaying the calling routine in the event of an error - i.e. why is the page looping around when an error is found? I guess something in the 'onclick' is somehow interpreting the validity of the page and redirecting back around when there are problems but I can't what is driving this.
ii) How I can expand the javascript routine with my own php code (I'm guessing I can't just add in php code to the function that Dreamweaver has written) to say, verify logon details against the db. If we go back around I can add in some extra code that will be executed on submit but if I get an error in my code, how do I convey that to the 'onclick' to take me back around again - the javascript function is in there already ... D'oh!
Are you with me? ...... is there anybody there ....
Thanks.
P.
