Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Can I get some help with this AJAX question?

Consider web forms where the user is asked to write some data (such as

name, email address, password, credit card, etc) that has to be validated before

it is used in the application. Describe two possible ways of providing form validation without Ajax and discuss how Ajax could be used in form validation and the advantages of doing so.

2 Answers

Relevance
  • Chris
    Lv 7
    6 years ago
    Favorite Answer

    Form validation can be done using simple JavaScript. Using the <form>'s onsubmit handler, one can do basic checks using plain JavaScript.

    Another way to check it is to send the form no matter what, then let the server-side scripting provide user feedback if the validation fails.

    AJAX can be used to validate the form in the background even if that requires server-side operations like database access.

    Say the user is filling out a form that requires a model number. AJAX can be used to check if the model number is in the database without sending the form.

  • 6 years ago

    Form validation should be started BEFORE sending the form, using javascript, ie to check if an email has a valid form, or data entered in some fields correspond to requirements.

    However, some checks can be made, also before sending the form, using an AJAX call, ie to check, during a registration, if the new user already exists or not in the database. and output an error message if it does.

    Credit cards, however, should NEVER be entered by the user, unless your site uses SSL (and it is formally registered). Leave CC checks to the approved payment gateway (ie PayPal). NEVER store sensitive details such as CC on an unsecure server.

    For your discussion, download the free script "basic php: using ajax" from http://webprosonly.com/

Still have questions? Get your answers by asking now.