Yahoo Clever wird am 4. Mai 2021 (Eastern Time, Zeitzone US-Ostküste) eingestellt. Ab dem 20. April 2021 (Eastern Time) ist die Website von Yahoo Clever nur noch im reinen Lesemodus verfügbar. Andere Yahoo Produkte oder Dienste oder Ihr Yahoo Account sind von diesen Änderungen nicht betroffen. Auf dieser Hilfeseite finden Sie weitere Informationen zur Einstellung von Yahoo Clever und dazu, wie Sie Ihre Daten herunterladen.
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 Antworten
- ChrisLv 7vor 6 JahrenBeste Antwort
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.
- just "JR"Lv 7vor 6 Jahren
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/