检查 formflow 上的用户输入
Checking User inputs on formflow
大家好,我正在使用 formflow,一切正常,我只是有一些小细节需要修复。
- 有没有办法让我通过正则表达式检查表单流中的用户输入?我需要检查用户是否输入了有效的姓名、电子邮件等
- 我可以将配置文件完成前的确认更改为是或否按钮,而不是键入是或否或 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();
}
}
所以这个问题已经一个月没有得到解答了,所以我希望你现在已经自己找到了答案。如果没有,这里有一个简单的方法:
[Pattern(@"Put pattern here")]
public string Email;
这种方式检查输入的字符串,如果输入错误会自动请求重试。
您在网上查找的大部分内容都有常用的模式。
post and this one 擅长展示自定义 FormFlow 的一些方法。
希望这有帮助。
编辑。抱歉错过了问题的第二部分。要添加一个简单的确认按钮,请将其添加到您的表单流中:
.Confirm("Thanks, please can you confirm everything below is correct {*} {||}")
“{*}”将显示所有字段和用户响应,“{||}”将显示您想要的 Yes/No 按钮。
大家好,我正在使用 formflow,一切正常,我只是有一些小细节需要修复。
- 有没有办法让我通过正则表达式检查表单流中的用户输入?我需要检查用户是否输入了有效的姓名、电子邮件等
- 我可以将配置文件完成前的确认更改为是或否按钮,而不是键入是或否或 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();
}
}
所以这个问题已经一个月没有得到解答了,所以我希望你现在已经自己找到了答案。如果没有,这里有一个简单的方法:
[Pattern(@"Put pattern here")]
public string Email;
这种方式检查输入的字符串,如果输入错误会自动请求重试。
您在网上查找的大部分内容都有常用的模式。 post and this one 擅长展示自定义 FormFlow 的一些方法。 希望这有帮助。
编辑。抱歉错过了问题的第二部分。要添加一个简单的确认按钮,请将其添加到您的表单流中:
.Confirm("Thanks, please can you confirm everything below is correct {*} {||}")
“{*}”将显示所有字段和用户响应,“{||}”将显示您想要的 Yes/No 按钮。