Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
请我正在尝试编写一个代码来快速检查用户输入是否是 QT 中的有效输入。
我希望它检查,如果它不符合通常的电子邮件格式,则不允许用户提交,但通知他电子邮件是错误的。
我已经看过 php 和一些 c++ 的示例,但根据我的经验,我不能像使用 Qt C++ 行编辑方法时那样快速地在 qt 中工作,所以想知道是否有人尝试过。
提前致谢。
使用此电子邮件验证 javascript 代码
function validateForm(email) { var atpos=email.indexOf("@"); var dotpos=email.lastIndexOf("."); if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length) { //Not a valid e-mail address return false; } }
阅读本文以了解如何将 javascript 导入 QML
http://doc.qt.nokia.com/4.7-snapshot/qdeclarativejavascript.html#importing-one-javascript-file-from-another