Jump to content

if isset javascript equivalent


Genesis5150

Recommended Posts

I'm looking for a solution for the javascript version of if isset in php. This is what I have:

if (typeof obj.office !='') 
  	{( document.listingform.office.value.length < 3 ); 
		{ if (valid)
      document.listingform.office.focus();
    document.listingform.office.style.border="solid 1px red";
    msg+="\"Office\" field cannot contain less than three characters\n";
    valid = false;
  }
	}

What I want to to do is if the field "office" holds a value and is less than three characters then alert but only if it has a value. How can I do that.

Link to comment
https://forums.phpfreaks.com/topic/297174-if-isset-javascript-equivalent/
Share on other sites

Thanks for the advice I went on and tried this but no luck:
 

if (obj.office && obj.office.length < 3) {
    if (valid)
      document.listingform.office.focus();
    document.listingform.office.style.border="solid 1px red";
    msg+="\"Office\" field cannot contain less than three characters\n";
    valid = false;
  }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.