html5 - Unexpected entry in a <select> field! How did this happen? -


in 1 of forms on website, have <select> field this:

<select name="doorno" required>             <option></option>             <option>01</option>             <option>02</option>             <option>03</option>             <option>04</option>             <option>05</option>             <option>06</option>             <option>07</option>             <option>08</option>             <option>09</option>             <option>10</option>             <option>11</option>             <option>12</option>             <option>13</option>             <option>14</option>             <option>15</option>             <option>16</option>             <option>17</option>             <option>18</option>             <option>19</option>             <option>20</option>             <option>21</option>             <option>22</option>             <option>23</option>             <option>24</option>         </select></p> 

the user should able select numbers between 01 - 24 - right?

but in table these entries stored, see entry like:

01,05 

how have happened? when try type field not able - can choose 1 of options in list?

any idea how user have managed enter option 1 above?

edit based on of comments looked backend of database , found user has made multiple selections. question has related question:

if not specify multiple attribute in select element, mean user can overcome default behaviour of single select?

easy, user has edited dom developer tools or using javascript. fact is, isn't user's fault.

it's yours!

you mustn't blindly trust input client, should validate you're expecting (in case, numbers between 1 , 24), you're getting. in case, can done with:

$input = (int) $input; if ($input > 0 && $input <= 24) { 

always validate input. always.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -