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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTC textbox field validation?

Status
Not open for further replies.

david7777777777

Programmer
Sep 26, 2001
417
0
0
US
I need to do field validation on a Textbox DTC. I'm assuming that JavaScript client-side validation won't work since these DTC's are server-side, right? Can someone give me a simple example of validating a textbox DTC please? My DTC is named txtDateReceived. I want to check to make sure the user does not enter any letters, but only numbers. Thanks.

 

You can do client side or server side validation. I prefer client side, becuse there's no server trip.

A simple example (you have one DTC textbox and one DTC button for saving):

<script language=JavaScript>
function thisPage_onbeforeserverevent(obj,evnt)
{
if (obj==&quot;btnSave&quot;){
if (event==&quot;onclick&quot;){
if (isNaN(document.thisForm.TextBox1.value)==true){
alert(&quot;Only numbers please.&quot;);
document.thisForm.TextBox1.focus();
thisPage.cancelEvent=true;
}
}
}
}
</script>

isNaN (is Not a Number) is a JavaScript function that checks if the value is a number. Problems are possible if you're allowing decimal places and your decimal operator is not the dafault one, then your validation should be diffrent.
&quot;Defeat is not the worst of failures. Not to have tried is the true failure.&quot;
-George E. Woodberry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top