Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > AJAX

AJAX Web based language that allows asynchronous loading of pages that does not interfere with normal page loading.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-11-2008, 04:03 PM
antonypeiris antonypeiris is offline
Newbie
 
Join Date: Sep 2007
Posts: 3
Rep Power: 0
antonypeiris is on a distinguished road
Default Ajax Form Help (validation and tips)

Hi Everyone,

I am very new to ajax and still learning. I am a server-side programmer so I ive forgotten most of what I use to know about things related to the client-side. Well, the complex JavaScript related stuff at least. Currently I am trying to teach myself how to get simple things done:

I have a form (that php generates through a class), and I can make it look like anything I please. Now I want to add client side validation process to it. For example:

if event = onKeyUp (for any input field) THEN
ACTION = check for validation (e.g. validate.php)

(my php scripts can take care of validation, and return a message if there is an error or nothing at all if none. I want ajax to send the field contents that the user just entered to the validate script onKeyUP)

if error THEN display a baloon tip *pop* and disable the submit button.

Then the user must correct the input and try again!

What do you guys think? I know there are frameworks that can help me to accomplish this very easily, but since im trying to learn I was wondering if someone here could push me in the right direction (to a tutorial or example code). I've done a bit of research, but still trying to get the hang of it.

Thanks a lot in advance!

Antony

EDIT: actually i think i should chance that onKeyUp to onChange right? The reason for this seems obvious.

Last edited by antonypeiris; 02-11-2008 at 04:16 PM. Reason: writoe something silly, and needed to correct myself
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 02-14-2008, 07:10 AM
fahlyn's Avatar   
fahlyn fahlyn is offline
Learning Programmer
 
Join Date: Nov 2007
Age: 24
Posts: 35
Rep Power: 3
fahlyn is on a distinguished road
Send a message via ICQ to fahlyn Send a message via AIM to fahlyn Send a message via MSN to fahlyn Send a message via Yahoo to fahlyn
Default

I see its been awhile since this post...did you ever figure anything out? What you want to accomplish is definitely doable...but I'd be careful using ajax with an onKeyUp event...that means that every time the user presses a key you're going to hit your server again...that is probably going to be excessive. What I would recommend is using Prototype.js. Take a look at the documentation on that web site. I'd check out Ajax.PeriodicalUpdater here. That would probably work better than going after an onKeyUp event.

Good Luck!
__________________
Visit My Google Group Here: Web Development Innovation
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-15-2008, 05:55 PM
antonypeiris antonypeiris is offline
Newbie
 
Join Date: Sep 2007
Posts: 3
Rep Power: 0
antonypeiris is on a distinguished road
Default

Hi,

Thank you so much for the advice, I appreciate it. I completely agree with you about the onKeyUp event (in fact, you might have missed the "EDIT" I put in there just after I posted my message, cos I realized it would mean too many requests to the server) ... as for a solution, well I didn't find exactly what I was looking for, but I designed a little js script myself based on what ive gathered from a various tutorials and implemented a way that would pop up a little message right below the field after an onChange event. This way it only validates it when the user has finished typing and moved the cursor to a new field. The only problem so far is that the last field in the form dosent get much attention since its usually the submit button after that. Know what I mean? I didn't figure out how to disable the submit button.. lol actually i forgot all about that, I just remembered after reading what I wrote.

I've heard of prototype, I will certainly give it a try. It is sort of an ajax frame work isnt it? Maybe I can look at the code and see if I can figure out how it works from the inside. Thanks again for the tip.

By the way, have you heard of ext.js ? It is also a framework, but it seems very bloated... have you ever tried it?

Thanks again and take care
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-15-2008, 07:20 PM
fahlyn's Avatar   
fahlyn fahlyn is offline
Learning Programmer
 
Join Date: Nov 2007
Age: 24
Posts: 35
Rep Power: 3
fahlyn is on a distinguished road
Send a message via ICQ to fahlyn Send a message via AIM to fahlyn Send a message via MSN to fahlyn Send a message via Yahoo to fahlyn
Default

prototype does supply some ajax helper classes...but not really a framework. Prototype really just adds additional functionally to the JavaScript language itself. It also provides helper classes for Strings, Arrays and Ajax. I have heard of ext.js, but I've never used it. I have used Mootools and Scriptaculous - which are JavaScript UI libraries. Yahoo also has some pretty neat JavaScript APIs.

As far as the submit button goes...what you can do is in your onBlur event or onChange (or whatever you're using) disable your submit button and change the text to "Validating..." (or whatever you want), then once your ajax callback method gets kicked off enable and change the text on your submit button. Actually, you wouldn't even need to disable the button...just check your flag when the user clicks the submit button and if that flag is set (and hasn't been reset by the ajax callback) give the user a message telling them that the form is still being validated....

you always want to be careful when using JavaScript to "turn off" submit buttons on forms....one thing to consider is, is it really worth making a separate HTTP request VIA ajax for EVERY form field...each Ajax request adds overhead to your application...so just keep performance in mind....it can make or break a web application.
__________________
Visit My Google Group Here: Web Development Innovation
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-15-2008, 10:01 PM
antonypeiris antonypeiris is offline
Newbie
 
Join Date: Sep 2007
Posts: 3
Rep Power: 0
antonypeiris is on a distinguished road
Default thank you

thank you again, for these excellent tips! You made me realize several important factors that I hadn't considered before. Also, I will try to apply the advice you suggested to for my problem. I greatly appreciate the help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 06:28 PM.

Contest Stats

John ........ 87.50000
dargueta ........ 75.00000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads