I have a standard input type text field that is supposed to trigger a Javascript whenever it is changed. First I tried onChange, however it just did nothing. Then I tried onBlur, but also here it did not do anything.
HTML Code:
<input type="text" size="1" class="inputbox" onblur="c();" name="qty" value="1" />
The Javascript should not be the problem, because I am triggering this with another select dropdown menu as well and there it works fine! Just on this text field it seems not to work. Anyways, here's the Javascript code:
function c() {
$('#add4').fadeOut(function(){
$('#add5').css('visibility', 'visible');
document.u.submit();
});
}
I checked online, but could not find any relevant posts or hints in this regard whatsoever. Any ideas what's wrong?
I have a standard input type text field that is supposed to trigger a Javascript whenever it is changed. First I tried onChange, however it just did nothing. Then I tried onBlur, but also here it did not do anything.
HTML Code:
<input type="text" size="1" class="inputbox" onblur="c();" name="qty" value="1" />
The Javascript should not be the problem, because I am triggering this with another select dropdown menu as well and there it works fine! Just on this text field it seems not to work. Anyways, here's the Javascript code:
function c() {
$('#add4').fadeOut(function(){
$('#add5').css('visibility', 'visible');
document.u.submit();
});
}
I checked online, but could not find any relevant posts or hints in this regard whatsoever. Any ideas what's wrong?
Share Improve this question asked Oct 29, 2013 at 17:09 KoljaKolja 8684 gold badges11 silver badges32 bronze badges 3- 2 Remove the inline event handler and use proper event handlers, and it will probably work, as I'm guessing wildly you put the c() function inside document ready or something else strange. – adeneo Commented Oct 29, 2013 at 17:12
- @adeneo, you should make your ment an answer. – Ishmael Commented Oct 29, 2013 at 17:16
- Is there an error in the console? – epascarello Commented Oct 29, 2013 at 17:18
2 Answers
Reset to default 3try this
<form>
<input id="target" type="text" value="Field 1">
<input type="text" value="Field 2">
</form>
<div id="other">
Trigger the handler
</div>
The event handler can be bound to the first input field:
$( "#target" ).blur(function() {
alert( "Handler for .blur() called." );
});
check this links for your reference http://api.jquery./blur/
http://www.w3schools./jquery/tryit.asp?filename=tryjquery_event_blur_alert
Hope this help
This may solve your problem:
<input type="text" size="1" class="inputbox" onblur=" javascript:c(); " name="qty" value="1" />