<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Test for NaN or undefined Coordinates? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/test-for-nan-or-undefined-coordinates/m-p/311609#M28669</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do not put quotes around &lt;EM&gt;undefined&lt;/EM&gt; and &lt;EM&gt;null&lt;/EM&gt; when doing a comparison like that. In one of my apps, I check whether a value is valid like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var value = registry.byId("textInput").value;
if (value !== "" &amp;amp;&amp;amp; value !== null &amp;amp;&amp;amp; value !== undefined) {
&amp;nbsp;&amp;nbsp; //do something
} &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the case of numeric value from a &lt;A href="http://dojotoolkit.org/reference-guide/1.10/dijit/form/NumberTextBox.html" rel="nofollow noopener noreferrer" target="_blank"&gt;NumberTextBox&lt;/A&gt;, I also check if it's a number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var value = registry.byId("numberInput").value;
if (value !== "" &amp;amp;&amp;amp; value !== null &amp;amp;&amp;amp; value !== undefined) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (registry.byId("numberInput") instanceof NumberTextBox) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!isNaN(value)) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //do something
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 14:54:15 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2021-12-11T14:54:15Z</dc:date>
    <item>
      <title>Test for NaN or undefined Coordinates?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/test-for-nan-or-undefined-coordinates/m-p/311607#M28667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a function that grabs coordinates from a text input box, and zooms to that point using centerAndZoom. I want to detect if the user enters something invalid, so I can pop up an alert informing them of the valid format, and abort the zoom. Currently it zooms to NaN, NaN if something invalid is entered.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The point retrieved from the textbox is called zoomPoint. I've tried:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (zoomPoint === "undefined")&lt;/P&gt;&lt;P&gt;if (zoomPoint === "NaN")&lt;/P&gt;&lt;P&gt;if (zoomPoint === null)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if ((zoomPoint.x === "undefined") || (zoomPoint.y === "undefined"))&lt;/P&gt;&lt;P&gt;if ((zoomPoint.x === "NaN") || (zoomPoint.y === "NaN"))&lt;/P&gt;&lt;P&gt;if ((zoomPoint.x === null) || (zoomPoint.y === null))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;None of these work when something invalid is entered, and the map zooms to coordinates NaN, NaN. When I popup an alert box containing zoompoint.x or zoompoint.y, the value shows as undefined - why doesn't the test if ((zoomPoint.x === "undefined") || (zoomPoint.y === "undefined")) work then?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Nov 2015 18:42:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/test-for-nan-or-undefined-coordinates/m-p/311607#M28667</guid>
      <dc:creator>LauraMiles1</dc:creator>
      <dc:date>2015-11-19T18:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: Test for NaN or undefined Coordinates?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/test-for-nan-or-undefined-coordinates/m-p/311608#M28668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Laura,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; If the input is a text box then the value of an empty text box would be "" not NaN unless you are using a Dojo NumberTextBox. Check for an empty string instead.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Nov 2015 18:57:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/test-for-nan-or-undefined-coordinates/m-p/311608#M28668</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-11-19T18:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Test for NaN or undefined Coordinates?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/test-for-nan-or-undefined-coordinates/m-p/311609#M28669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do not put quotes around &lt;EM&gt;undefined&lt;/EM&gt; and &lt;EM&gt;null&lt;/EM&gt; when doing a comparison like that. In one of my apps, I check whether a value is valid like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var value = registry.byId("textInput").value;
if (value !== "" &amp;amp;&amp;amp; value !== null &amp;amp;&amp;amp; value !== undefined) {
&amp;nbsp;&amp;nbsp; //do something
} &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the case of numeric value from a &lt;A href="http://dojotoolkit.org/reference-guide/1.10/dijit/form/NumberTextBox.html" rel="nofollow noopener noreferrer" target="_blank"&gt;NumberTextBox&lt;/A&gt;, I also check if it's a number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var value = registry.byId("numberInput").value;
if (value !== "" &amp;amp;&amp;amp; value !== null &amp;amp;&amp;amp; value !== undefined) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (registry.byId("numberInput") instanceof NumberTextBox) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!isNaN(value)) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //do something
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:54:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/test-for-nan-or-undefined-coordinates/m-p/311609#M28669</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-12-11T14:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: Test for NaN or undefined Coordinates?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/test-for-nan-or-undefined-coordinates/m-p/311610#M28670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have also tried testing for &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;zoomPoint.x or y === "", but this did not work. zoomPoint is actually a geometry point, not the text box contents - I'm trying to determine if the user entered valid coordinates, ie. in case the user puts an "N" before or after the longitude, or gets some other text characters in by accident, etc - I think Ken's answer is working for this.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Nov 2015 19:12:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/test-for-nan-or-undefined-coordinates/m-p/311610#M28670</guid>
      <dc:creator>LauraMiles1</dc:creator>
      <dc:date>2015-11-19T19:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: Test for NaN or undefined Coordinates?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/test-for-nan-or-undefined-coordinates/m-p/311611#M28671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep, thanks Ken - for some reason NetBeans was showing an error when I first tried undefined without the quotations, but it's working now!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Nov 2015 19:13:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/test-for-nan-or-undefined-coordinates/m-p/311611#M28671</guid>
      <dc:creator>LauraMiles1</dc:creator>
      <dc:date>2015-11-19T19:13:17Z</dc:date>
    </item>
  </channel>
</rss>

