简体   繁体   English

表单提交前的 REACT JS 强制字段检查

[英]REACT JS mandatory field check before form submission

I need to develop a react form with multiple fields are marked as mandatory without which form should not be submitted.我需要开发一个具有多个字段的反应表单,这些字段被标记为强制性的,没有哪些表单不应提交。

What are the easiest way to do this?最简单的方法是什么? Is there are props for each field level by which I can apply check before submission?是否有针对每个字段级别的道具,我可以通过这些道具在提交前申请检查? Or any other easy way?或者还有什么简单的方法吗? Please help请帮忙

I'm not completely sure what you are looking for.我不完全确定你在找什么。 You could do something like this, it might be the easiet way.你可以做这样的事情,这可能是最简单的方法。

But you might want some validation for your form - checkout yup on npmjs.com但是您可能需要对您的表单进行一些验证 - 在 npmjs.com 上签出 yup

<input type="text" required/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM