472,126 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,126 software developers and data experts.

ajax form validation

pradeepjain
563 512MB
hii guys ,
I wanna share a very gud ajax validation script with php...
Ajax Form Validation - sForm | chains.ch weblog

I am very new to ajax .So i wanna small help....i want to improve that script with adding checkbox,radiobutton validation and dropdown list validation . but i am not able to do it.....any one can add his/her code into that ajax script..tht i can have a look at it..

And i have found a small bug in tht script ...say the submit button will be active by default which it shld not be..


thanks,
Pradeep
Nov 30 '08 #1
3 1981
Logician
210 100+
@pradeepjain
I cannot see the point of that code; it makes multiple server requests to perform a task that can be done client-side. It's certainly no substitute for conventional server-side validation, which is still essential. It looks like AJAX for the sake of it.
Nov 30 '08 #2
pradeepjain
563 512MB
@Logician
so wht do u think....ajax validation for client side is waste of resource is it....so we need to make a client side and server side validation is it...so whats the main use of ajax ..where must we use it..
Nov 30 '08 #3
Ajax is good for validating specific things that would be too much to send in the initial document. Like for a checkbox it would be best to use a server side to throw in a variable that you would use to ensure the form is filled out correctly.

Expand|Select|Wrap|Line Numbers
  1. form.onsubmit = function ()
  2. {
  3. return (window.getElementById ("tosagreed").checked == (true))
  4. }
Ajax would be good for (these are examples)...
  1. Checking that a username isn't already taken.
  2. Getting a long list of cities/provinces and sticking them into a drop down box when a user picks a specific country/state.
  3. Getting a list of online people on a page that is not meant to be refreshed (like a chat room).
  4. Saving stuff to the server you are actively editing (take a look at Google Documents, and Spreadsheets) so that you don't lose any information if your browser crashes.

Ajax isn't really the best choice for some of the things that sForm uses it for. Email validation, for example, can be done without using Ajax at all. With or without Ajax, though, you should always use server-side verification for everything no matter what. Because if it's client-side, they can get around it. The purpose of Ajax is to let users know that they are good to go before they submit, knowing they probably wont get a, "you filled the form out wrong!"
Nov 30 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

31 posts views Thread by Tony | last post: by
5 posts views Thread by Martin | last post: by
1 post views Thread by John Chan | last post: by
5 posts views Thread by lucyh3h | last post: by
1 post views Thread by Mark B | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.