Input (Bootstrap 5): Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
Created page with "frameless|Input (BS5) File:Bsdatalist.png == Description == The Input control allows a single line of input text. It has optional headers, footers and other features. Note that Input (Bootstrap) does not have .text property. Use .value to get the value of the control. To disable an Input at runtime, do the following: <pre> Input1_contents.disabled = true </pre> To highlight an Input control with an error (and return it to normal): <pre>..."
 
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:Bs5input.png|frameless|Input (BS5)]]
[[File:Bs5input.png|frameless|Input (BS5)]]
[[File:Bsdatalist.png]]
[[File:Bsdatalist.png]]
= Input, Input-Group and Input-Item =
The Input, Input-Group and Input-Item controls are used together. All are covered in this entry, since they require each other.


== Description ==
== Description ==


The Input control allows a single line of input text. It has optional headers, footers and other features.
The Input control allows a single line of input text. It has optional headers, help text and other features.
It works by having a base 'Input' control to which you add one or more InputItem controls.
The InputItems can be inputText, span, textarea, chackbox or radio items.
An Input control can have multiple InputItems, which allowed you to build a complex input line.
 
In the above sample, the 'Name' input control has a 'span', and 'input' and another 'span'.


Note that Input (Bootstrap) does not have .text property. Use .value to get the value of the control.
Construct by adding an Input-group control to your project, then by dropping Input-item controls into it,
then customize each InputItem by setting its ItemType.


To disable an Input at runtime, do the following:
To disable an Input at runtime, disable the InputItem:
<pre>
<pre>
   Input1_contents.disabled = true
   ipiInput1.disabled = true
</pre>
</pre>


To highlight an Input control with an error (and return it to normal):
To highlight an InputItem control as invalid (and return it to normal):


<pre>
<pre>
   $("#Input1").addClass("has-error")
   ipiInput1.classList.add("is-invalid")
   $("#Input1").removeClass("has-error")
   ipiInput1.classList.remove("is-invalid"))
</pre>
</pre>


To hide and show the Help text:
You can also highlight an InputItem as valid
 
<pre>
<pre>
   $("#Input1 .help-block").addClass("hidden")
   ipiInput1.classList.add("is-valid")
   $("#Input1 .help-block").removeClass("hidden")
</pre>
 
To change the Help text:
<pre>
   ipiInput1.innerText = "Some help text for the user"
</pre>
</pre>


[[Introduction_to_Bootstrap#Popovers_and_Tooltips|Popovers and Tooltips]] are supported.
[[Introduction_to_Bootstrap#Popovers_and_Tooltips|Popovers and Tooltips]] are supported.


== Properties and Methods ==
== Properties and Methods - Input Control ==
 
Standard [[properties and methods|properties]] are supported, plus:
{| class="wikitable"
|-
| help || An optional message at the bottom of the list of items. Design Time and Runtime.
|-
| label || An optional message at the bottom of the list of items. Design Time and Runtime.
|-
|}
 
== Properties and Methods - InputItem control ==


Standard [[properties and methods|properties]] are supported, plus:
Standard [[properties and methods|properties]] are supported, plus:
Line 39: Line 65:
| autocorrect || Spellcheck as entering? May not be available on other platforms.
| autocorrect || Spellcheck as entering? May not be available on other platforms.
|-
|-
| badge || Adds a Badge to the control. Design Time and Runtime.
| datalist || List of possible predefined values, one per line. Design Time and Runtime.
|-
|-
| datalist || List of possible predefined values, one per line. Bootstrap 4 only. Design Time and Runtime.
| disabled || If true, grays out the input area and prevents changes. Runtime.
|-
| disabled || If true, grays out the input area and prevents changes. Design Time and Runtime.
|-
|-
| files || Array of files chosen if inputType is 'file'. Runtime.
| files || Array of files chosen if inputType is 'file'. Runtime.
|-
|-
| focus() || Sets the focus to the TextBox. Runtime only.
| focus() || Sets the focus to the TextBox. Runtime only.
|-
| footer || An optional message at the bottom of the list of items. Design Time and Runtime.
|-
| header || An optional message at the bottom of the list of items. Design Time and Runtime.
|-
| headerCols || Width to be allocated to the header. Can be from 0 to 12. Default is 2. headerCols + valueCols must equal 12.
|-
| icon || An optional [http://fontawesome.io/ icon] to appear at the right of the input field. Design Time and Runtime.
|-
|-
| inputmode || Specifies what kind of keyboard should display on mobile devices. Not all browsers support all types. Bootstrap 4 only. Design time.<br><b>(empty)</b> Use the default keyboard.<br><b>none</b> This keyword is useful for content that renders its own keyboard control.<br><b>text</b> Display keyboard capable of text input in the user's locale.<br><b>tel</b> Display keyboard capable of telephone number input. This should including keys for the digits 0 to 9, the '#' character, and the '*' character. In some locales, this can also include alphabetic mnemonic labels (e.g., in the US, the key labeled '2' is historically also labeled with the letters A, B, and C).<br><b>url</b> Display keyboard capable of text input in the user's locale, with keys for aiding in the input of URLs, such as that for the '/' and '.' characters and for quick input of strings commonly found in domain names such as 'www.' or '.com'.<br><b>email</b> Display keyboard capable of text input in the user's locale, with keys for aiding in the input of e-mail addresses, such as that for the '@' character and the '.' character.<br><b>numeric</b> Display keyboard capable of numeric input. This keyword is useful for PIN entry.<br><b>decimal</b> Display keyboard capable of fractional numeric input. Numeric keys and the format separator for the locale should be shown.<br><b>search</b> Display keyboard optimized for search.
| inputmode || Specifies what kind of keyboard should display on mobile devices. Not all browsers support all types. Bootstrap 4 only. Design time.<br><b>(empty)</b> Use the default keyboard.<br><b>none</b> This keyword is useful for content that renders its own keyboard control.<br><b>text</b> Display keyboard capable of text input in the user's locale.<br><b>tel</b> Display keyboard capable of telephone number input. This should including keys for the digits 0 to 9, the '#' character, and the '*' character. In some locales, this can also include alphabetic mnemonic labels (e.g., in the US, the key labeled '2' is historically also labeled with the letters A, B, and C).<br><b>url</b> Display keyboard capable of text input in the user's locale, with keys for aiding in the input of URLs, such as that for the '/' and '.' characters and for quick input of strings commonly found in domain names such as 'www.' or '.com'.<br><b>email</b> Display keyboard capable of text input in the user's locale, with keys for aiding in the input of e-mail addresses, such as that for the '@' character and the '.' character.<br><b>numeric</b> Display keyboard capable of numeric input. This keyword is useful for PIN entry.<br><b>decimal</b> Display keyboard capable of fractional numeric input. Numeric keys and the format separator for the locale should be shown.<br><b>search</b> Display keyboard optimized for search.
Line 61: Line 77:
| inputType || Specifies what kind of data will be input. Choices are color, date, datetime, email, file, hidden, month, number, password, range, search, tel, text, time and url. Default is text. Not all browsers support all types. Design time.
| inputType || Specifies what kind of data will be input. Choices are color, date, datetime, email, file, hidden, month, number, password, range, search, tel, text, time and url. Default is text. Not all browsers support all types. Design time.
|-
|-
| leftText || Text to appear in the left side of the input box. HTML is allowed. Does not display if container < 768 pixels.
| itemType || Specifies what kind of field it is. Options are inputText, span (some text to display), textarea, checkbox and radio. Design time.
|-
|-
| max || If inputType is numeric, the maximum allowed value. For date, the latest date in the format YYYY-MM-DD.
| max || If inputType is numeric, the maximum allowed value. For date, the latest date in the format YYYY-MM-DD.
Line 82: Line 98:
|-
|-
| setSelectionRange(start, end) || Selects a range of characters. The first character starts at 0. Runtime only. <br>Input1_contents.setSelectionRange(2,4)
| setSelectionRange(start, end) || Selects a range of characters. The first character starts at 0. Runtime only. <br>Input1_contents.setSelectionRange(2,4)
|-
| size || Size of input text: small or large. Header and footer size is controlled by fontSize. Design time only.
|-
|-
| spellcheck || Check spelling and grammer?
| spellcheck || Check spelling and grammer?
|-
|-
| value || Gets or sets the value (true or false) of line i. Runtime.
| value || Gets or sets the value (true or false) of line i. Runtime.
|-
| valueCols || Width to be allocated to the value. Can be from 0 to 12. Default is 10. headerCols + valueCols must equal 12.
|}
|}


Line 102: Line 114:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
// JavaScript
// JavaScript
Input1.onfocusout = function() {
ipiInput1.onfocusout = function() {
     NSB.MsgBox("Value is " + Input1.value);
     NSB.MsgBox("Value is " + ipiInput1.value);
};
};
</syntaxhighlight>
</syntaxhighlight>
Line 110: Line 122:
<syntaxhighlight lang="vb.net">
<syntaxhighlight lang="vb.net">
' Basic
' Basic
Function Input1_onfocusout()
Function ipiInput1_onfocusout()
   MsgBox "Value is " & Input1.value
   MsgBox "Value is " & ipiInput1.value
End Function
End Function
</syntaxhighlight>
</syntaxhighlight>
Line 117: Line 129:




To respond to a click on the optional icon:
To respond to a click on a span item:
<tabber>
<tabber>
  JavaScript=
  JavaScript=
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
// JavaScript
// JavaScript
Input1_icon.onclick = function() {
ipiSpan3Help.onclick = function() {
   NSB.MsgBox("You can display a message or take other action when clicked");
   NSB.MsgBox("You can display a message or take other action when clicked");
};
};
Line 130: Line 142:
<syntaxhighlight lang="vb.net">
<syntaxhighlight lang="vb.net">
' Basic
' Basic
Function Input1_icon_onclick()
Function ipiSpan3Helpn_onclick()
   MsgBox "You can display a message or take other action when clicked"
   MsgBox "You can display a message or take other action when clicked"
End Function
End Function
Line 141: Line 153:
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
// JavaScript
// JavaScript
Input1.datalist = ["Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday"];
ipiInput1.datalist = ["Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday"];
</syntaxhighlight>
</syntaxhighlight>
|-|
|-|
Line 147: Line 159:
<syntaxhighlight lang="vb.net">
<syntaxhighlight lang="vb.net">
' Basic
' Basic
Input1.datalist = ["Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday"]
ipiInput1.datalist = ["Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday"]
</syntaxhighlight>
</syntaxhighlight>
</tabber>
</tabber>

Latest revision as of 13:43, 12 June 2023

Input (BS5)

Input, Input-Group and Input-Item

The Input, Input-Group and Input-Item controls are used together. All are covered in this entry, since they require each other.

Description

The Input control allows a single line of input text. It has optional headers, help text and other features. It works by having a base 'Input' control to which you add one or more InputItem controls. The InputItems can be inputText, span, textarea, chackbox or radio items. An Input control can have multiple InputItems, which allowed you to build a complex input line.

In the above sample, the 'Name' input control has a 'span', and 'input' and another 'span'.

Construct by adding an Input-group control to your project, then by dropping Input-item controls into it, then customize each InputItem by setting its ItemType.

To disable an Input at runtime, disable the InputItem:

  ipiInput1.disabled = true

To highlight an InputItem control as invalid (and return it to normal):

  ipiInput1.classList.add("is-invalid")
  ipiInput1.classList.remove("is-invalid"))

You can also highlight an InputItem as valid

  ipiInput1.classList.add("is-valid")

To change the Help text:

  ipiInput1.innerText = "Some help text for the user"

Popovers and Tooltips are supported.

Properties and Methods - Input Control

Standard properties are supported, plus:

help An optional message at the bottom of the list of items. Design Time and Runtime.
label An optional message at the bottom of the list of items. Design Time and Runtime.

Properties and Methods - InputItem control

Standard properties are supported, plus:

autocapitalize Automatically capitalize first letter? May not be available on other platforms.
autocomplete Automatically complete words? May not be available on other platforms.
autocorrect Spellcheck as entering? May not be available on other platforms.
datalist List of possible predefined values, one per line. Design Time and Runtime.
disabled If true, grays out the input area and prevents changes. Runtime.
files Array of files chosen if inputType is 'file'. Runtime.
focus() Sets the focus to the TextBox. Runtime only.
inputmode Specifies what kind of keyboard should display on mobile devices. Not all browsers support all types. Bootstrap 4 only. Design time.
(empty) Use the default keyboard.
none This keyword is useful for content that renders its own keyboard control.
text Display keyboard capable of text input in the user's locale.
tel Display keyboard capable of telephone number input. This should including keys for the digits 0 to 9, the '#' character, and the '*' character. In some locales, this can also include alphabetic mnemonic labels (e.g., in the US, the key labeled '2' is historically also labeled with the letters A, B, and C).
url Display keyboard capable of text input in the user's locale, with keys for aiding in the input of URLs, such as that for the '/' and '.' characters and for quick input of strings commonly found in domain names such as 'www.' or '.com'.
email Display keyboard capable of text input in the user's locale, with keys for aiding in the input of e-mail addresses, such as that for the '@' character and the '.' character.
numeric Display keyboard capable of numeric input. This keyword is useful for PIN entry.
decimal Display keyboard capable of fractional numeric input. Numeric keys and the format separator for the locale should be shown.
search Display keyboard optimized for search.
inputType Specifies what kind of data will be input. Choices are color, date, datetime, email, file, hidden, month, number, password, range, search, tel, text, time and url. Default is text. Not all browsers support all types. Design time.
itemType Specifies what kind of field it is. Options are inputText, span (some text to display), textarea, checkbox and radio. Design time.
max If inputType is numeric, the maximum allowed value. For date, the latest date in the format YYYY-MM-DD.
maxlength Maximum number of input characters. Does not apply to numeric: use max instead.
min If inputType is numeric, the minimum allowed value. For date, the earliest date in the format YYYY-MM-DD.
minlength Minimum number of characters for text input. Not used for inputType number.
name Key in submitted form
passwordToggle Option to toggle plaintext for Password fields.
placeholder Text to be displayed in the field just as a comment – does not change the value.
readOnly If set to “True”, the control cannot be edited. At runtime, use readOnly.
required If set to “True”, the field requires a value when the form is submitted. Design time only.
setSelectionRange(start, end) Selects a range of characters. The first character starts at 0. Runtime only.
Input1_contents.setSelectionRange(2,4)
spellcheck Check spelling and grammer?
value Gets or sets the value (true or false) of line i. Runtime.

Events

Standard events are supported. For this control, the onfocusin and onfocusout events will be useful. They are called when the user changes the focus to another field.

Example

Call a function when user is done editing field.

// JavaScript
ipiInput1.onfocusout = function() {
    NSB.MsgBox("Value is " + ipiInput1.value);
};

' Basic
Function ipiInput1_onfocusout()
  MsgBox "Value is " & ipiInput1.value
End Function


To respond to a click on a span item:

// JavaScript
ipiSpan3Help.onclick = function() {
  NSB.MsgBox("You can display a message or take other action when clicked");
};

' Basic
Function ipiSpan3Helpn_onclick()
  MsgBox "You can display a message or take other action when clicked"
End Function

To change the datalist at runtime:

// JavaScript
ipiInput1.datalist = ["Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday"];

' Basic
ipiInput1.datalist = ["Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday"]

Output