Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

OnTextChanged serverside event not fire when i am apply jquery mask function. Textchanged event fire when another postback event fired only.


Please help me.

Thanks in advance....
Posted
Comments
Really !!! Can you please post the code snippets only for the TextBox, so that we can test?
swathi(MCA) 21-Apr-15 2:06am    
<script type="text/javascript" src="../Scripts/jquery-1.4.1.min.js"></script>
<script src="../Scripts/MaskInput.js" type="text/javascript"></script>
<script type="text/javascript">

$(document).ready(function () {
$("input[id$='txtSessionStTime']").blur(function () {
var userInput = $(this).val().replace(/^([0-9])([0-9]):([0-9])_$/, "0$1:$2$3");
if (!userInput.match(/([0-1][0-9]|2[0-3]):[0-5][0-9]/)) {
alert('invalid Time');
$(this).val('');

} else {
$(this).val(userInput);
return true;
};
}).mask("99:99");


});


</script>

This is the Jquery function i have applied for Mask and valid Time.
Refer my answer Solution 3.

When jQuery is being used for mask or any other operation which are related to keyPress,Up or Down they are mostly using event.preventDefault()[^].
Quote:
If this method is called, the default action of the event will not be triggered.


So this can be a reason that your Textchanged event is not executing.
 
Share this answer
 
Comments
swathi(MCA) 21-Apr-15 1:57am    
Then how to fire Textchanged event, please share the information as early as possible. It's very urgent...
Refer my answer Solution 3.
Couple of changes.

Script


XML
<script type="text/javascript">
    $(document).ready(function () {
        $("input[id$='txtSessionStTime']").blur(function () {
            var userInput = $(this).val().replace(/^([0-9])([0-9]):([0-9])_$/, "0$1:$2$3");

            if (!userInput.match(/([0-1][0-9]|2[0-3]):[0-5][0-9]/)) {
                alert('invalid Time');
                $(this).val('');

                return false;
            } else {
                $(this).val(userInput);

                return true;
            };
        }).mask("99:99");
    });
</script>

Markup


XML
<asp:TextBox ID="txtSessionStTime" runat="server" OnTextChanged="txtSessionStTime_TextChanged"
            AutoPostBack="true"></asp:TextBox>
 
Share this answer
 
Comments
swathi(MCA) 25-Apr-15 3:14am    
i have set the property AutopostBack="true" previous also, and now i have update the "return false;" statement. still it's not fire the server side event.
It is perfectly firing for me. I think you have some other issues? Have you debugged?
I am using javascript instead of Jquery. refer the below link.

http://www.dotnetspider.com/resources/35694-Mask-Input-Time-Format-using-javascript.aspx
 
Share this answer
 

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