How to allow the user input to be only
-Ve or +Ve
using java script.
I have tried something as follows but it is not allowing any value in the text box to be entered.
function rhFactor(txtBoxObj)
{
var pve = "+ve";
var nve = "-ve";
var ve = false;
if( validTxtBoxObj(txtBoxObj))
{
if(pve == txtBoxObj.value || nve == txtBoxObj.value )
{
ve = true;
}
if(ve == false)
{
// alert('Allowed RH Factors - +ve,-ve');
txtBoxObj.value="";
}
return false;
}
return true;
}
This is how i called
onkeyup="rhFactor(this)"
UPDATE :
function validTxtBoxObj(txtBoxObj)
{
if(txtBoxObj != null) return true;
return false
}
Please help me to get this work.