Form Validation

So…onward from my attempts to validate form input  (Week7 PHP Guestbook exercise). Although I got the script working (and have since disabled it!) using this resource, I was not satisfied with the script (pregmatch/or die), for the reasons aptly described here. In a nutshell, bouncing somebody out of a page (both the ‘or die’ and ‘exit’ commands do this) when they have made a mistake with a form will at the very least annoy them and most likely lose you a user. I thought the better way was for an alert or error message to be displayed (without losing all the form data) and have found a some code here and here that I will be trying out, hopefully in the next few days (remembering to add a comment in the code crediting the source). The previous code I tried was PHP (ie server side) but the scripts I am going to experiment with are Javascript, so this will fulfil the client side validation before I cross over to the dark–I mean server–side.

Julie

PS Have been viewing source code on web pages a fair bit lately, just to deconstruct how a web page has been, well, constructed. Sometimes it’s fairly readable, sometimes not.  It does give me some code examples to follow up, mostly on the CSS side, but also allows me to try and figure out how the JavaScript has been put together (special interest in form pages!). Hopefully it will help when constructing my final project–given that I only came equipped with minimal HTML coding skill and even less CSS 🙂

I’ve also been trying to put things into practice on my own site as I go, as much as I can (ie within the time I have) as it really helps!

References

JavaScript Form Validation : quick and easy!. 2012. JavaScript Form Validation : quick and easy!. viewed 25 April 2012, < http://www.javascript-coder.com/html-form/javascript-form-validation.phtml.>

PHP Freaks – PHP Help or die() must die viewed 24 April 2012, <http://www.phpfreaks.com/blog/or-die-must-die>.

Validating E-mail and URL viewed 24 April 2012, <http://myphpform.com/validating-url-email.php>.

JavaScript Form Validation. 2012. JavaScript Form Validation. viewed 25 April 2012, < http://www.w3schools.com/js/js_form_validation.asp>

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: