Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > handling onblur

Reply
Thread Tools

handling onblur

 
 
hrpreet
Guest
Posts: n/a
 
      02-16-2006
Hi All,

I have few textfields and dropdowns in my jsp, form is submitted on
clicking an image link.
In case there is an error for instance some text field is left empty,
then message is displayed below respective fields ( using spans, inner
html). The message is displayed onblur event of the field. So if there
was an error then message is displayed, now if the user corrects the
error and clicks the link then first the message disaapears ,which is
desired ,but he has to click again to submit the form. please suggest a
way to handle this. So that user doesn't have to click the link twice
to submit the form.I tried having onmousedown and onfocus events on
image , but then sometimes the form was submitted twice which gave
backend errors.

Thanks

 
Reply With Quote
 
 
 
 
web.dev
Guest
Posts: n/a
 
      02-16-2006

hrpreet wrote:
> Hi All,
>
> I have few textfields and dropdowns in my jsp, form is submitted on
> clicking an image link.
> In case there is an error for instance some text field is left empty,
> then message is displayed below respective fields ( using spans, inner
> html). The message is displayed onblur event of the field. So if there
> was an error then message is displayed, now if the user corrects the
> error and clicks the link then first the message disaapears ,which is
> desired ,but he has to click again to submit the form. please suggest a
> way to handle this. So that user doesn't have to click the link twice
> to submit the form.I tried having onmousedown and onfocus events on
> image , but then sometimes the form was submitted twice which gave
> backend errors.
>
> Thanks


A form element has an onsubmit event handler. Consider using that to
validate your form instead of using onblur. For example:

html:

<form action = "action.jsp" method = "post" onsubmit = "return
validate(this)">
....[elements]...
</form>

javascript:

function validate(myForm)
{
//perform your validation routine here
if(...)
{
//display your error message
//return false will cause the form NOT to submit
return false;
}

//return true will cause the form to submit
return true;
}

It would be also nice to take into consideration if the user has
disabled javascript. Therefore you should also do validation on the
server side.

 
Reply With Quote
 
 
 
 
hrpreet
Guest
Posts: n/a
 
      02-17-2006
Thanks a lot for your reply.
But it was client's requirement to hav it onblur. i kept trying
different options, and capturing onmouse down event on image has helped
me.

You are right about server side validations.

Thanks again

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Anomaly: onblur handling AND advice on validation Emmes Javascript 1 01-30-2008 06:52 AM
custom control onblur postback neil S via DotNetMonster.com ASP .Net 1 04-27-2005 11:58 PM
Client Side OnBlur Triggering Validation =?Utf-8?B?Sm9lLkRhdHRpbG8=?= ASP .Net 1 06-18-2004 09:06 PM
Adapting onBlur functionality of javascript in ASP.net?? Jeffrey ASP .Net 2 10-16-2003 06:48 AM
Javascript onblur prevents users to select dropdownlist simo sentissi ASP .Net 0 08-25-2003 05:07 PM



Advertisments