Validating a form using php rowupdating event of the dataadapter

We make an Ajax call to our processing page – where it does the validation in our PHP code previously.

Now, remember our server side will echo a JSON object with our field names and error messages?

validating a form using php-42validating a form using php-60validating a form using php-56

Validating a form using php

AJAX (Asynchronous Java Script and XML) is the art of exchanging data with a server, and updating parts of a web page – without reloading the whole page. We have already explained about form validation using different technologies.

Now, the same can be done by using Ajax, In this blog post we will tell you how it can be done.

Oh and of course, we will also have the good user experience of the page not refreshing when there’s errors. You can also have the processing page the same as the page where the form is. Copy the code below into your HTML: Nothing fancy here. Remember to make your field names unique – for this is what we’ll use to validate our form.

Keep in mind that you will need a bit of programming know how – especially in PHP and Javascript. So when our form submits, it passes the $_POST array to this page.

The code below is to be added to our form page: Plenty of things going on above.

Of course everything is wrapped inside our document.ready() handler, then we put a .click() for our submit button.

Plenty argue (including myself), that server side validation is more secure.

This is because client side validation can be manipulated (or simply turned off).

But for the sake of our tutorial, I want to make it short and concise.

I prefer to write j Query, so the code below will only work if j Query is included.

But the bad thing about server side validation – is you see the page refresh.

Tags: , ,