2017-09-15 87 views
0

嗨,大家好我使用formflow,一切都很顺利,我只是有一些小细节需要修复。在Formflow上检查用户输入

  • 有没有办法让我通过正则表达式检查用户在Formflow中的输入?我需要检查用户是否输入了有效的姓名,电子邮件等。
  • 我可以在配置文件完成之前将确认更改为yes或no按钮,而不是键入yes或no或y或n吗?

下面是所以这个尚未在一个月内答复,所以我现在希望你已经发现自己的答案代码

[Serializable] 
public class ProfileForm 
{ 
    [Prompt("What is your first name? {||}")] 
    public string FirstName; 
    [Prompt("What is your last name? {||}")] 
    public string LastName; 
    [Prompt("What is your email? {||}")] 
    public string Email; 

    public static IForm<ProfileForm> BuildForm() 
    { 
     return new FormBuilder<ProfileForm>() 
       .Message("Welcome to the profile bot!") 
       .OnCompletion(async (context, profileForm) => 
       { 
        // Tell the user that the form is complete 
        await context.PostAsync("Your profile is complete."); 
       }) 
       .Build(); 
    } 
} 
+0

修改了我的答案,回答你的问题的第二部分,希望它有帮助。 – Witted

回答

0

。如果不是,这里是一个简单的方法:

[Pattern(@"Put pattern here")] 
    public string Email; 

这样检查输入字符串,并会自动请求另一次尝试,如果正确输入。

对于大部分您在网上寻找的东西,都有常用的图案。 这postthis one擅长展示一些定制FormFlows的方法。 希望这有助于。

编辑。对不起错过了问题的第二部分。要添加一个简单的确认按钮添加到您的formflow:

.Confirm("Thanks, please can you confirm everything below is correct {*} {||}") 

的“{*}”将显示所有字段和用户的反应和“{} ||”会显示是/否按钮,你要。