Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Validation in QML



  • Hello,

    There is something not very clear in documentation.

    Say, I am using RegExpValidator for e-mail address form field.

    How to trigger validation of this field upon submission of the form?

    Currently, with the correctly set validator property of the TextField QML type, I am able to leave the field with malformed e-mail address and there is no complaint shown in the user interface.

    What am I missing?

    Thank you in advance.



  • When validator is set you can use acceptableInput property of input, to check if it valid.



  • @intruderexcluder said in Validation in QML:

    When validator is set you can use acceptableInput property of input, to check if it valid.

    Excellent!

    I have now noticed how this relates to accepted() signal and onAccepted handler.

    Thank you for the prompt reply.


Log in to reply