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

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.