Reputation: 18560
I have a simple form like this:
<form id='myForm'>
<input type='text' name='Textbox'>
<select name='SelectBox'>
<option class='option1'>option 1</option>
<option class='option2'>option 2</option>
</select>
</form>
I want to capture this form's Textbox focus lost (blur) event and SelectBox change event.
I don't want to apply change event for whole form because it causing to submit form more than one time.
Upvotes: 1
Views: 1747
Reputation: 1782
Add id='SelectBox'
to your select box and id='Textbox'
to your text box and try the following:
function handleTextBoxBlur(event, element) {
console.log("blur");
console.log(element);
}
function handleSelectBoxChange(event, element) {
console.log("change");
console.log(element);
}
document.observe("dom:loaded", function(event) {
$("Textbox").on("blur", "input", handleTextBoxBlur);
$("SelectBox").on("change", "select", handleSelectBoxChange);
});
Upvotes: 3
Reputation: 1
$('input').focus_lost(function() { /write what Ever code need/ });
$('option').change(function() { /write what Ever code need/ });
/This is suitable only for this given form..Learn more from a link >and http://jqueryui.com//
Upvotes: 0