JavaScript check field value based on variable value
<p>I have an anchor like this:</p>

<pre><code>&lt;a href="#" rel="1 4 7 18 "&gt;Anchor&lt;/a&gt;
</code></pre>

<p>Where 'rel' attribute values are ids of some items.<br />
Than I have a form with an input, where user should type an id and click submit button.<br />
On submit button click I need to check the value of input like this:</p>

<pre><code>var value = $('a').attr('rel'); // get anchor 'rel' ids
var uservalue = $('input[type='text']').val();
if ( uservalue == '1' || uservalue == '4' || uservalue == '7' || uservalue == '18') {
// however I need the line above are created dynamically based on 'value' var
  alert('The id exists');
  return false;
} else {
  return true;
}
</code></pre>

<p>So, the question is how to create a line below dynamically based on anchor 'rel' attribute values?!<br />
This is the line:</p>

<pre><code>if ( value == '1' || value == '4' || value == '7' || value == '18') {
</code></pre>
