Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validating a Text Box (simple question)

Status
Not open for further replies.

jreinard

Technical User
Feb 21, 2001
24
0
0
US
I am trying to force the validation of a text box through a script. I have a text box named cost_center1. When cost_center1 is equal to 1999, the form will then submit.

I do not believe I have it called properly... It seems that it is not recognizing the if statement properly.

Any help is greatly appreciated.


function DoOnSubmit(f)
{
if(f.cost_center1.value != '1999')
{
alert("Please enter a valid cost center or po number!");
f.cost_center1.focus();
return false;
}
else
{
return true;
}
return true;
}
</SCRIPT> -->
 
function DoOnSubmit()
{
var objTxtB=document.getElementById(&quot;cost_center1&quot;);

if(parseInt(objTxtB.value) != 1999 ){
alert(&quot;Please enter a valid cost center or po number!&quot;);
objTxtB.focus();
return false;
}else{
return true;
}
return true;
}

* Make sure your &quot;cost_center1&quot; ID is set.
Exmp: <input type=textbox ID=cost_center1>
&quot;did you just say Minkey?, yes that's what I said.&quot;

MrGreed
 
and don't forget to call your function from your onSubmit by doing onsubmit=&quot;return DoOnSubmit()&quot; if you're calling it that way.

faq216-2809 Hope I helped / Thanks for helping
if ((Math.abs(x)<10&&Math.abs(y)<10) && (((parseInt(Math.abs(x).toString()+Math.abs(y).toString())-Math.abs(x)-Math.abs(y))%9)!=0)) {alert(&quot;I'm a monkey's uncle&quot;);}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top