javascript - Both onBlur and onChange not working with <input type="text" - Stack Overflow

I have a standard input type text field that is supposed to trigger a Javascript whenever it is changed

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
Add a ment  | 

2 Answers 2

Reset to default 3

try 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" />

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745498128a4630286.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信