As an example, I have a dialog that opens when adding a new contact. It looks similar to the following:
<dialog id="newContact" title="" subtext="">
<body>
<text-input bind=... label=... />
.
.
.
<text-input bind='number' label=... />
</body>
</dialog>
<button-group>
<button label="Cancel" on-press="$:Cancel()" validate="false" />
<button label="Save" on-press="$:Submit()" validate="true"/>
</button-group>
I want to verify that the user enters a phone number of 10 digits. I tried using another dialog to route to the check and notify if the user has entered a number less than 10 digits. See below:
<dialog id="newContact" title="" subtext="">
<body>
<text-input bind=... label=... />
.
.
.
<dialog id="checkNumber" .... /> <-- NEW DIALOG
<text-input bind='number' label=... />
</body>
</dialog>
<button-group>
<button label="Cancel" on-press="$:Cancel()" validate="false" />
<button label="Save" on-press="$:Submit()" validate="true"/>
</button-group>
I tried adding a check into my on-press
on the Save
button and calling the checkNumber
dialog. The dialog pops up but then closes the newContact
dialog before the user can even press anything. Even if I call the newContact
dialog again. I would like to make the dialog work, however, if it cannot, what's the best way to check the length of a text-input
?
Right now I'm implementing return notification.error(....)
, but I'd rather have another dialog because the notification cancels out the newContact
dialog and the user has to add a new contact again.