For a textbox that accept numbers as shown below, how can the default value be set to 0?
<input name="smtpPort" type="number" id="smtpPort" size="30" maxlength="50" class="input-full" tabindex="4" value="{{model.PortNumber}}">
Though the value in DB is null, it still shows 0 in textbox.
Any help would be appreciated.
right click on your database -- select design--select required column--in column properties, general tab you will see the "default value or binding". Mention 0 here.
On the Tools menu, click Form Options. Click Advanced in the Category list, and then click Edit Default Values. In the Edit Default Values dialog box, select the field whose default value you want to set.
keypress(function(evt) { if (evt. which == "0".
HTML attribute to set a default value is value
:
<input type="number" value="1">
You're setting this default value to null
, and nothing (in HTML) can change it to zero (or anything else).
You must fix the value in your database, or in your template engine (something like {{model.PortNumber || 0}}
).
At least, you can force your field to be filled with required
attribute:
<input type="number" required value="">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With