-1

I have a text box in a form that is validated to accept a value called ds01 but i also want the textbox to be allowed to accept empty spaces that is if nothing is entered in the textbox. The problem is that it does not accept anything other than ds01. Thanx in advance for your help. This is my script

function validate_choice(field,alerttxt)
{
with (field)
  {
  if (value != "ds01")
    {
    alert(alerttxt);return false;
    }
  else if (value ==null || value == "" || value=="ds01")
    {
    return true;
    }
  }
}

function validate_form(thisform)
{
with (thisform)
  {
  if (validate_choice(webdev, "You Must Enter the Correct Code.Please Enter ds01!.Thank You!")==false)
  {webdev.focus();return false;}
  }
}

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.

Votes + Comments
This isn't your first post, use code tags. Hell, there's even a code tag button
2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Troy III
0

I have a text box in a form that is validated to accept a value called ds01 but i also want the textbox to be allowed to accept empty spaces that is if nothing is entered in the textbox. The problem is that it does not accept anything other than ds01. Thanx in advance for your help. This is my script

function validate_choice(field,alerttxt)
{
with (field)
{
if (value != "ds01")
{
alert(alerttxt);return false;
}
else if (value ==null || value == "" || value=="ds01")
{
return true;
}
}
}

function validate_form(thisform)
{
with (thisform)
{
if (validate_choice(webdev, "You Must Enter the Correct Code.Please Enter ds01!.Thank You!")==false)
{webdev.focus();return false;}
}
}

Here you go

function validate_choice(field,alerttxt){
with (field){
if (value ==null || value == "" || value=="ds01"){
    return true;
    }
else if (value != "ds01"){
    alert(alerttxt);
    return false;
    }
  }
}

*the part in red is not needed, but doesn't cause problems...

0

Thanx a lot for your help. That has solved my problem. Thank you

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.