Note that there are some explanatory texts on larger screens.

plurals
  1. POValidating multiple options with if statement
    primarykey
    data
    text
    <p>I am having an issue validating that a field is empty or full. The code below will help.</p> <p>The below is not the whole piece of my form, just the part you need to know. <b>HTML:</b></p> <pre><code>&lt;form action="" method="post" id="all_message"&gt; &lt;ul&gt; &lt;li&gt; &lt;label for="subject"&gt;Subject&lt;/label&gt;&lt;br /&gt; &lt;select id="No_dropdown" name="Dropown_select"&gt; &lt;option value="Request for quote"&gt;Request for quote&lt;/option&gt; &lt;option value="Service inquiries"&gt;Service inquiries&lt;/option&gt; &lt;option value="Other"&gt;Other&lt;/option&gt; &lt;/select&gt; &lt;/li&gt; &lt;li&gt; &lt;input type="submit" value="Send" name="submit" /&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/form&gt; </code></pre> <p>I use this script to make a no selection on the select option above. <b>Javascript</b></p> <pre><code>&lt;script language="javascript" type="text/javascript"&gt; document.getElementById("No_dropdown").selectedIndex = -1; &lt;/script&gt; </code></pre> <p>This is not the whole PHP for it, just the part I'm having trouble with. <b>PHP:</b></p> <pre><code>$subject = $_POST['Dropown_select']; if (empty($name) === true || empty($email) === true || empty($phone) === true || !($subject === "Other" || "Service inquiries" || "Request for quote") || empty($message) === true ) </code></pre> <p>This is the part I am having troubles with:</p> <pre><code>!($subject === "Other" || "Service inquiries" || "Request for quote") </code></pre> <p>I need that part to see if one of the 'dropdowns' is selected and if not give an error.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload