Monday, November 3, 2008

AjaxForm methods

Method

Description

submit()

You can submit the form by calling this function, but it is not necessary to use it usually, for example you can set the last field onBlure event to a function which calls this method.

reset()

You can reset the form and clear the message board by calling this method, but it is not necessary usually and it is called from other methods of the class.

resetForm()

You can reset the form but not clear the message board by calling this method.

hideForm()

This method will hide the form element (form tag). You may call this function when the server script has processed the data and the process was successful and user won't need the form anymore, similar to the login forms after successful login.

showMessage(msg, color)

This method let you show a message to the user such as data validation messages. The firs parameter is the message itself which is string and the second one is the color of message which is string too and could contain a color name e.g. "red" or a color value e.g. "#FF0000"

focusForm()

By calling this method the first input of the form will receive the focus. You may call this method after creating the object in order to make form ready to receive user's data.

2 comments:

Amir H. Fassihi said...

This is very interesting Ehsun, keep up the good work. Does it have validation features (Ajaxified) too?
Maybe if you directed this project towards an ajax form generator, that would be really cool too.

Seven said...

Thanks :)
I have worked on form generators in some companies before, but at the moment I'd like to keep the idea simple and flexible! But validation is a good idea to be added.
I'm working on AjaxContent and AjaxTab (which is actually more than a tab view class) classes right now. I've developed AjaxSearch class also, but I don't like its architecture and design. So I will amend it or redesign it later.