[英]trigger field validation on form submit
i have a text input component which has a validator input prop for field level validation which gets triggered by event like clicking the field. 我有一个文本输入组件,该组件具有用于字段级验证的验证器输入道具,该输入器由诸如单击字段之类的事件触发。 I am using the text-input component multiple times in a form.
我在表单中多次使用文本输入组件。 How do i trigger field level validation for all text-inputs on form submit.
如何触发表单提交中所有文本输入的字段级别验证。
<form id="update-for-homeaddress" action="/mycontact" method="POST" onSubmit={this.handleSubmit}>
<Label labelFor="Nickname" labelText="Nickname:" required/>
<TextInput inputName="Nickname"
inputType="text"
value={this.props.myhomeaddress.AddressAlias}
onChange={()=>{}}
validator={ValidateFactory.getMandatoryCheck()}
ref="TextInputRef"
/>
I suggest moving this code into a tag below. 我建议将这段代码移到下面的标签中。 Put an ID in the form tag
在表单标签中放置一个ID
then using this 然后用这个
$('document').ready(function()
{
//Jquery validation codes
$("#my_form").validate({
submitHandler: submitForm
});
function submitForm()
{
//Submit form from here
}
}
You need the jquery validation plugin here, you can add different validations then on 您需要在此处使用jquery验证插件,然后可以添加其他验证
https://jqueryvalidation.org https://jqueryvalidation.org
I hope this helps in any way. 我希望这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.