Click here to Skip to main content
15,895,462 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How to use onblur event in javascript validation
Posted
Comments
choudhary.sumit 12-Dec-12 4:59am    
which one is question why or how??
Raman Thakur 12-Dec-12 5:04am    
when some control lost focus and you want to call any function on lost focus.
for example when textbox lost focus and I want to implement validation so we can use that.

The onblur event occurs when an object loses focus.

Onblur is most often used with form validation code (e.g. when the user leaves a form field).

Write a java script function and call that function as shown below :

txtCreditLimit.Attributes.Add("onBlur", "javascript:return fnMyFunctionBlur()");

Here, txtCreditLimit is your control id and fnMyFunctionBlur() is your java script function.

(Or)

<input type="text" onblur="fnMyFunctionBlur()">
 
Share this answer
 
Answer to the title - I basically use it for validations of textboxes using javascript. But I don't have any idea why you are using it unless you tell me so.

Answer to the post body - http://www.w3schools.com/jsref/event_onblur.asp
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900