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

ajax form check

P: 63
I'm tolly new to ajax and I want to combine ajax, php and html to build a form where I can check the validity of the input data. There'll be warning right when I finish typing the word, for example "username must be at least 6 characters"

anyone knows how to perform this?
Nov 20 '07 #1
Share this Question
Share on Google+
2 Replies

P: 34
u cud use something like this

[HTML]<input name="name" type="text" onkeyup="validate(event);" />[/HTML]

and the javascript function

Expand|Select|Wrap|Line Numbers
  1. function validate(e) {
  2. if (this.value.length < 6 ) {
  3. var nameerror = document.getElementById('nameerrordiv');
  4. nameerror.innerHTML = "name should be longer than 6 characters";
  5. }
  6. }
i used a div to show the error message because using alert would be rather trouble some when the user types the first 6 letters.
Nov 20 '07 #2

Expert Mod 15k+
P: 16,027
Just a note that this makes no use of AJAX, but plain old DHTML - nothing more is needed for the task.
Nov 21 '07 #3

Post your reply

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