By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,738 Members | 1,730 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,738 IT Pros & Developers. It's quick & easy.

ajax form validation

pradeepjain
100+
P: 563
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
Share this Question
Share on Google+
3 Replies


100+
P: 210
@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
100+
P: 563
@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

P: 65
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.