Click here to Skip to main content
16,018,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Inside a form I am using a textbox as "Mobile no" and i want to validate that textbox in different different tabs because i am calling the same form in all the tabs:
the tabs are:
1.Prepaid tab
2.Postpaid tab
3.Dth tab
4.data card tab

now when user navigate to first tab,second tab or fourth tab the mobile no textbox should accept only 10 digit but when fourth tab is called it should accept any no of digit

What I have tried:

function IsNumeric(e) {
var specialKeys = new Array();
specialKeys.push(8); //Backspace
var keyCode = e.which ? e.which : e.keyCode
var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);
document.getElementById("error").style.display = ret ? "none" : "inline";
return ret;
}
function ValidateRecharge(rdvalue) {
debugger;
var MobileNo = document.getElementById("txtMobileNo").value;
var amt = document.getElementById("txtAmount").value;
var errorMsg = '';
if(errorMsg==''){
if (MobileNo == "") {
errorMsg += "Please Enter Mobile No.|";
}
//else {
// if (MobileNo.length < 10 || MobileNo.length > 10) {
// errorMsg += "Mobile No. is not valid, Please Enter 10 Digit Mobile No.|";
// }
//}
if (amt == "") {
errorMsg += "Please Enter Amount.|";
}
}

if (errorMsg == '') {
document.getElementById('btnRechargeNow_Click').click();
}
else {
document.getElementById('lblErrorMsg').innerHTML = ShowMessage(errorMsg);
return false;
}
}
Posted
Updated 8-Nov-16 6:02am

1 solution

Any attempt to work with tabs in this way is doomed to fail. Tabs are something implemented by the browser, they are not part of web standards so there is no way of knowing or controlling what happens in other tabs.
 
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