471,306 Members | 931 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

onBlur validation not calling properly when press enterkey(not mouse click)

raj
hi,
i have one textbox and one save button, i have added attribute at page
load event

btnSave.Attributes.Add("onclick","return ValidateForm();");

in validationform() ,I have written like this

if(--some validation function here--)
{
----------------
return false;
--------------
}

if(window.confirm ('Are you sure to Save ?'))
return true;
else
return false;
at .aspx page i am writing

<asp:textbox id="txtCompAdj" Runat="server"
onblur="cspFormat(this,30,8,'');return false;"></asp:textbox>

now the problem i am facing that suppose cspFormat returns false(means
some error) then in that case i am getting the prompt "Are you sure to
Save ?"

i.e. the execution sequence is when we press enter key
1) validateForm()
2) cspformat(----)

if i press the button by mouse then the execution sequence is just
reverse which is perfectly write and dont provide "Are you sure to Save
?" prompt if there is any error(return false) in cspformat(---)

so what should i do to get the proper execution sequence at enter press
event as i get at mouse pree event

Nov 19 '05 #1
3 2206
raj,

Is there a reason you aren't using the built in validators?

If you use the validation objects .NET has given you and still attach your
confirmation then the confirmation "Are you sure to save?" would pop first
and then the validators would take care of everything else for you.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"raj" <Ra***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
hi,
i have one textbox and one save button, i have added attribute at page
load event

btnSave.Attributes.Add("onclick","return ValidateForm();");

in validationform() ,I have written like this

if(--some validation function here--)
{
----------------
return false;
--------------
}

if(window.confirm ('Are you sure to Save ?'))
return true;
else
return false;
at .aspx page i am writing

<asp:textbox id="txtCompAdj" Runat="server"
onblur="cspFormat(this,30,8,'');return false;"></asp:textbox>

now the problem i am facing that suppose cspFormat returns false(means
some error) then in that case i am getting the prompt "Are you sure to
Save ?"

i.e. the execution sequence is when we press enter key
1) validateForm()
2) cspformat(----)

if i press the button by mouse then the execution sequence is just
reverse which is perfectly write and dont provide "Are you sure to Save
?" prompt if there is any error(return false) in cspformat(---)

so what should i do to get the proper execution sequence at enter press
event as i get at mouse pree event

Nov 19 '05 #2
you should also hookup your validation code to the onsubmit event and cancel
if error

<script>
document.forms[0]onsubmit = new function {
return ValidateForm();
}
</script>

-- bruce (sqlwork.com)
"raj" <Ra***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
hi,
i have one textbox and one save button, i have added attribute at page
load event

btnSave.Attributes.Add("onclick","return ValidateForm();");

in validationform() ,I have written like this

if(--some validation function here--)
{
----------------
return false;
--------------
}

if(window.confirm ('Are you sure to Save ?'))
return true;
else
return false;
at .aspx page i am writing

<asp:textbox id="txtCompAdj" Runat="server"
onblur="cspFormat(this,30,8,'');return false;"></asp:textbox>

now the problem i am facing that suppose cspFormat returns false(means
some error) then in that case i am getting the prompt "Are you sure to
Save ?"

i.e. the execution sequence is when we press enter key
1) validateForm()
2) cspformat(----)

if i press the button by mouse then the execution sequence is just
reverse which is perfectly write and dont provide "Are you sure to Save
?" prompt if there is any error(return false) in cspformat(---)

so what should i do to get the proper execution sequence at enter press
event as i get at mouse pree event

Nov 19 '05 #3
raj
hi bruce,
i put ValidationForm() at onsubmit event but still its following the
same sequence ,that problem still persist,

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Charles Shao | last post: by
6 posts views Thread by nickwang | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.