onchange
Description
Fires on change of the value of an input, i.e. on the HTML input eventUsage
onchange?: (ev: { value: string | number; input?: boolean }) => void;
Parameters
value
- (required) the value of the inputinput
- (optional) true, if text is being typed (check details)
Example
<script>
function handleChange(ev){
const text = ev.value;
console.log(text);
// => {"the typed text"}
}
</script>
<Text placeholder="Type here" onchange={handleChange}/>
Details
The handler function receives an object with the text typed in the input. The received object may also contain input:true
, depending on the fired HTML input event:
- if the input event of the HTML input is caught (a text is being typed), the
change
event of the Text control will haveinput:true
- if the change event of the HTML input is caught (a user has applied changes), the
change
event of the Text control won't have theinput
property
Related article: Catching the change of the value