Enforce Node edit dialog TypedInput

I created a node that has a number input field.
When text or characters are entered the input box highlights red but i'm still able to deploy.
Is there a way to enforce a number only input field?

<script type="text/javascript">
    RED.nodes.registerType('phonenumber',{
        category: '_SMS_',
        color: '#3FADB5',
	paletteLabel: "Phone Number",
        defaults: {
            name: {value:""},
	    number: {value:""}	
        },
        inputs:1,
        outputs:1,
        icon: "font-awesome/fa-phone",
        label: function() {
            return this.name + " " + this.number||"Phone Number";
        },
	oneditprepare: function(){
		$("#node-input-number").typedInput({
   		 type:"num",
    		types:["num"],
    		typeField: "#node-input-number-type"
	})
	}
    });
</script>

<script type="text/html" data-template-name="phonenumber">
    <div class="form-row">
        <label for="node-input-name"><i class="fa fa-user"></i>Name</label>
        <input type="text" id="node-input-name" placeholder="Name">
    </div>
    <div class="form-row">
        <label for="node-input-number"><i class="fa fa-mobile"></i>Number</label>
        <input type="text" id="node-input-number" placeholder="17801234567">
	<input type="hidden" id="node-input-number-type">
    </div>
</script>
<type="text/html" data-help-name="phonenumber">
    <p>Enter Phone Number</p>
</script>

Hi @JohnnyPicnic,
And if you change your input type from "text" to "number" (see here)?
Bart

[EDIT] Now I am doubting whether it should be "text" always for a TypedInput. But cannot test at this moment...

Yup that did it.
Thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.