Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #31512

Re: How to check existance of the element value in Javascript

Newsgroups comp.lang.javascript
Subject Re: How to check existance of the element value in Javascript
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <63599b54-703c-4db4-ac68-2eb4275357ba@googlegroups.com>
Date 2016-10-04 20:58 +0200
Message-ID <XnsA697D54B2C51Ceejj99@194.109.6.166> (permalink)

Show all headers | View raw


vinodtiwari10@gmail.com wrote on 04 Oct 2016 in comp.lang.javascript:

> I have XML stored in the variable 'ad' and 'addd':

You can only store a STRING containing text with xml-source in a variable


[...]

> 
> I have written a `ttt` function:

>     function ttt(ad,addd) {
>     var match = ad.match(/<Id\/>/);
>     var matcht = addd.match(/<Id\/>/);

If you want to test something in a string, use test() not match(),
and preferable don't use function words as variable names.

var adTest = /<Id\/>/.test(ad);
var adddTest = /<Id\/>/.test(addd);

>     if ((! match || match.length == 0) && 
>       (! matcht || match.length == 0 )
>     

if (!adTest && !adddTest) 
     alert('both tests are false');

Is that what you expected?

[..]
 
> I need `If` `Id` is not blank from ad variable then return alert as
> `error` with `Id` as below: 

"is not blank from ad variable" 

I do not understand that senstense, could you refrase?

=================

Please give your name as signature.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

How to check existance of the element value in Javascript vinodtiwari10@gmail.com - 2016-10-04 11:23 -0700
  Re: How to check existance of the element value in Javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-10-04 20:58 +0200

csiph-web