Reputation: 16219
I want to clear a 2nd textbox value
when i'm doing focus (or changing value)
of 1st textbox
using jquery
?
I'm trying to use
$(document).ready(function () {
validateFocus();
});
function validateFocus() {
$('#1stTextBox').focus(function () {
$('2nsTextBox').val('');
});
}
not working for me help me to correct me thanks
Upvotes: 0
Views: 519
Reputation: 3610
you have missed the selector here $('2nsTextBox').val('');
function validateFocus() {
$('#1stTextBox').focus(function () {
$('#2nsTextBox').val('');// may be # if its id, no need to tell u other selectors by seeing ur rep
});
}
Upvotes: 0
Reputation: 3862
can you please check this demo :
[jsfiddle.net/malvaniya_shakti/V25g5/4/][1]
Upvotes: 0
Reputation: 600
Try this
$(document).ready(function(e) {
$('#txt1').focus(function() {
$('#txt2').attr('value','');
});
});
Upvotes: 2
Reputation: 9947
See if this works.
$(input[id$='firsttextboxid']).focus(function() {
$("#secondtextboxid").val('');
});
Upvotes: 0
Reputation: 7689
The question is quiet unclear.. If you want to clear another textbox, you can simply call it as you did for the txtDate;
if(!checkDate($("#txtDate").val()))
{
$("#txtDate").val("");
$('#txtDate').focus();
$("#Your2ndTextBox").val("");
}
This should be enough..
Upvotes: 0
Reputation: 2174
if(!checkDate($("#txtDate").val()))
{
$("#txtDate").val("");
$('#txtDate').focus();
}
you forgot # on this $("txtDate").val()
Upvotes: 0