ravichandran
Mar 15th 2008, 2:46 am
hello,
i am using javascript for to make digits validation in one text box.
the following are the allowable input for that particular text box
1.That is in first digit should be 1
2.the second digit should be between 1to6
3.the third digit shoule be (.)dot
4.forth and final digit should be between 1to9
In that process 1 and 2 are working good.
3 and 4 not working properly.
my coding is as followsfunction validatecredit(x)
{
var maintainplus = '';
var numval = x.value;
if (numval.charAt(0)=='1')
{
alert("1");
if(numval.charAt(1)>'0'|| numval.chatAt(1)>7)
{
alert("2");
if(numval.charAt(2))
{
alert("3");
if(numval.charAt(3))
{
alert("4");
if(numval.charAt(4))
{
alert("5");
curphonevar=numval.replace(/[\\A-Za-z!";£$%^&*+_={};:'@#~,.¦\/<>?|`¬\]\[]/g,'');
x.value = maintainplus + curphonevar;
var maintainplus = '';
x.focus;
return true;
}
else
{
curphonevar=numval.replace(/[\\A-Za-z!"£$%^&*+_={};:'@#~,.¦\/<>?|`¬\]\[]/g,'');
x.value = maintainplus + curphonevar;
var maintainplus = '';
x.focus;
return true;
}
}
else
{
curphonevar=numval.replace(/[\\A-Za-z!"£$%^&*+_={};:'@#~,.¦\/<>?|`¬\]\[]/g,'');
x.value = maintainplus + curphonevar;
var maintainplus = '';
x.focus;
return true;
}
}
else
{
curphonevar=numval.replace(/[\\A-Za-z!"£$%^&*+_={};:'@#~,¦\/<>?|`¬\]\[]/g,'');
x.value = maintainplus + curphonevar;
var maintainplus = '';
x.focus;
return true;
}
}
else
{
alert("else 2");
curphonevar=numval.replace(/[\\A-Za-z2-9!"£$%^&*+_={};0:'@#~,.¦\/<>?|`¬\]\[]/g,'');
x.value = maintainplus + curphonevar;
var maintainplus = '';
x.focus;
return true;
}
}
else
{
alert("else 1");
curphonevar=numval.replace(/[\\A-Za-z2-9!"£$%^&*+_={};0:'@#~,.¦\/<>?|`¬\]\[]/g,'');
x.value = maintainplus + curphonevar;
var maintainplus = '';
x.focus;
return true;
}
}
pls help us to make process 3 and 4 to work well
plsreply me if u know the answer
i am using javascript for to make digits validation in one text box.
the following are the allowable input for that particular text box
1.That is in first digit should be 1
2.the second digit should be between 1to6
3.the third digit shoule be (.)dot
4.forth and final digit should be between 1to9
In that process 1 and 2 are working good.
3 and 4 not working properly.
my coding is as followsfunction validatecredit(x)
{
var maintainplus = '';
var numval = x.value;
if (numval.charAt(0)=='1')
{
alert("1");
if(numval.charAt(1)>'0'|| numval.chatAt(1)>7)
{
alert("2");
if(numval.charAt(2))
{
alert("3");
if(numval.charAt(3))
{
alert("4");
if(numval.charAt(4))
{
alert("5");
curphonevar=numval.replace(/[\\A-Za-z!";£$%^&*+_={};:'@#~,.¦\/<>?|`¬\]\[]/g,'');
x.value = maintainplus + curphonevar;
var maintainplus = '';
x.focus;
return true;
}
else
{
curphonevar=numval.replace(/[\\A-Za-z!"£$%^&*+_={};:'@#~,.¦\/<>?|`¬\]\[]/g,'');
x.value = maintainplus + curphonevar;
var maintainplus = '';
x.focus;
return true;
}
}
else
{
curphonevar=numval.replace(/[\\A-Za-z!"£$%^&*+_={};:'@#~,.¦\/<>?|`¬\]\[]/g,'');
x.value = maintainplus + curphonevar;
var maintainplus = '';
x.focus;
return true;
}
}
else
{
curphonevar=numval.replace(/[\\A-Za-z!"£$%^&*+_={};:'@#~,¦\/<>?|`¬\]\[]/g,'');
x.value = maintainplus + curphonevar;
var maintainplus = '';
x.focus;
return true;
}
}
else
{
alert("else 2");
curphonevar=numval.replace(/[\\A-Za-z2-9!"£$%^&*+_={};0:'@#~,.¦\/<>?|`¬\]\[]/g,'');
x.value = maintainplus + curphonevar;
var maintainplus = '';
x.focus;
return true;
}
}
else
{
alert("else 1");
curphonevar=numval.replace(/[\\A-Za-z2-9!"£$%^&*+_={};0:'@#~,.¦\/<>?|`¬\]\[]/g,'');
x.value = maintainplus + curphonevar;
var maintainplus = '';
x.focus;
return true;
}
}
pls help us to make process 3 and 4 to work well
plsreply me if u know the answer