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

R

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
 
S

S. Justin Gengo

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
 
B

Bruce Barker

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)
 
R

raj

hi bruce,
i put ValidationForm() at onsubmit event but still its following the
same sequence ,that problem still persist,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top