I want to show Error message in ReactJS Form












0















I am new to reactJS i want to show Error message when someone leave empty filed. Form is already validated but not able to display error message.I Copied this form code from (ant-design) i will share it link to view original form and it working fine but in my form the error message is not working .
Original Form link Form Link



My Form Code



import React from 'react';
import styled from 'styled-components';
import 'antd/dist/antd.css';
import Input from 'antd/lib/input';

const FormCard = styled.div`
max-width: 100%;
overflow: hidden;
transition: all 0.3s cubic-bezier(0.41, 0.094, 0.54, 0.07) 0s;
margin-top: 30px;
`;

const FormItem = styled.div`
font-family: 'Chinese Quote', -apple-system, BlinkMacSystemFont, 'Segoe UI',
'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue',
Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol';
font-size: 14px;
font-variant: tabular-nums;
color: rgba(0, 0, 0, 0.65);
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
list-style: none;
margin-bottom: 18px;
vertical-align: top;
`;

class RegisterStepOne extends React.Component {
render() {
const { getFieldDecorator } = this.props;
return (
<div>
<FormCard>
<FormItem label="E-mail">
{getFieldDecorator('firstName', {
rules: [
{
required: true,
message: 'Please input your First name!',
whitespace: true,
},
],
})(<Input placeholder="First name" />)}
</FormItem>
<FormItem label="E-mail">
{getFieldDecorator('lastName', {
rules: [
{
required: true,
message: 'Please input your Last name!',
whitespace: true,
},
],
})(<Input placeholder="Last name" />)}
</FormItem>
<FormItem label="E-mail">
{getFieldDecorator('email', {
rules: [
{
type: 'email',
message: 'The input is not valid E-mail!',
},
{
required: true,
message: 'Please input your E-mail!',
},
],
})(<Input placeholder="Email" />)}
</FormItem>

<FormItem>
{getFieldDecorator('lastPosition', {
rules: [
{
required: true,
message: 'Please input your Last Position!',
whitespace: true,
},
],
})(<Input placeholder="Present or last position" />)}
</FormItem>

<FormItem>
{getFieldDecorator('lastCompany', {
rules: [
{
required: true,
message: 'Please input your Last Company!',
whitespace: true,
},
],
})(<Input placeholder="Present or last Company" />)}
</FormItem>
</FormCard>
</div>
);
}
}
export default RegisterStepOne;









share|improve this question



























    0















    I am new to reactJS i want to show Error message when someone leave empty filed. Form is already validated but not able to display error message.I Copied this form code from (ant-design) i will share it link to view original form and it working fine but in my form the error message is not working .
    Original Form link Form Link



    My Form Code



    import React from 'react';
    import styled from 'styled-components';
    import 'antd/dist/antd.css';
    import Input from 'antd/lib/input';

    const FormCard = styled.div`
    max-width: 100%;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.41, 0.094, 0.54, 0.07) 0s;
    margin-top: 30px;
    `;

    const FormItem = styled.div`
    font-family: 'Chinese Quote', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue',
    Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
    'Segoe UI Symbol';
    font-size: 14px;
    font-variant: tabular-nums;
    color: rgba(0, 0, 0, 0.65);
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    list-style: none;
    margin-bottom: 18px;
    vertical-align: top;
    `;

    class RegisterStepOne extends React.Component {
    render() {
    const { getFieldDecorator } = this.props;
    return (
    <div>
    <FormCard>
    <FormItem label="E-mail">
    {getFieldDecorator('firstName', {
    rules: [
    {
    required: true,
    message: 'Please input your First name!',
    whitespace: true,
    },
    ],
    })(<Input placeholder="First name" />)}
    </FormItem>
    <FormItem label="E-mail">
    {getFieldDecorator('lastName', {
    rules: [
    {
    required: true,
    message: 'Please input your Last name!',
    whitespace: true,
    },
    ],
    })(<Input placeholder="Last name" />)}
    </FormItem>
    <FormItem label="E-mail">
    {getFieldDecorator('email', {
    rules: [
    {
    type: 'email',
    message: 'The input is not valid E-mail!',
    },
    {
    required: true,
    message: 'Please input your E-mail!',
    },
    ],
    })(<Input placeholder="Email" />)}
    </FormItem>

    <FormItem>
    {getFieldDecorator('lastPosition', {
    rules: [
    {
    required: true,
    message: 'Please input your Last Position!',
    whitespace: true,
    },
    ],
    })(<Input placeholder="Present or last position" />)}
    </FormItem>

    <FormItem>
    {getFieldDecorator('lastCompany', {
    rules: [
    {
    required: true,
    message: 'Please input your Last Company!',
    whitespace: true,
    },
    ],
    })(<Input placeholder="Present or last Company" />)}
    </FormItem>
    </FormCard>
    </div>
    );
    }
    }
    export default RegisterStepOne;









    share|improve this question

























      0












      0








      0








      I am new to reactJS i want to show Error message when someone leave empty filed. Form is already validated but not able to display error message.I Copied this form code from (ant-design) i will share it link to view original form and it working fine but in my form the error message is not working .
      Original Form link Form Link



      My Form Code



      import React from 'react';
      import styled from 'styled-components';
      import 'antd/dist/antd.css';
      import Input from 'antd/lib/input';

      const FormCard = styled.div`
      max-width: 100%;
      overflow: hidden;
      transition: all 0.3s cubic-bezier(0.41, 0.094, 0.54, 0.07) 0s;
      margin-top: 30px;
      `;

      const FormItem = styled.div`
      font-family: 'Chinese Quote', -apple-system, BlinkMacSystemFont, 'Segoe UI',
      'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue',
      Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
      'Segoe UI Symbol';
      font-size: 14px;
      font-variant: tabular-nums;
      color: rgba(0, 0, 0, 0.65);
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      list-style: none;
      margin-bottom: 18px;
      vertical-align: top;
      `;

      class RegisterStepOne extends React.Component {
      render() {
      const { getFieldDecorator } = this.props;
      return (
      <div>
      <FormCard>
      <FormItem label="E-mail">
      {getFieldDecorator('firstName', {
      rules: [
      {
      required: true,
      message: 'Please input your First name!',
      whitespace: true,
      },
      ],
      })(<Input placeholder="First name" />)}
      </FormItem>
      <FormItem label="E-mail">
      {getFieldDecorator('lastName', {
      rules: [
      {
      required: true,
      message: 'Please input your Last name!',
      whitespace: true,
      },
      ],
      })(<Input placeholder="Last name" />)}
      </FormItem>
      <FormItem label="E-mail">
      {getFieldDecorator('email', {
      rules: [
      {
      type: 'email',
      message: 'The input is not valid E-mail!',
      },
      {
      required: true,
      message: 'Please input your E-mail!',
      },
      ],
      })(<Input placeholder="Email" />)}
      </FormItem>

      <FormItem>
      {getFieldDecorator('lastPosition', {
      rules: [
      {
      required: true,
      message: 'Please input your Last Position!',
      whitespace: true,
      },
      ],
      })(<Input placeholder="Present or last position" />)}
      </FormItem>

      <FormItem>
      {getFieldDecorator('lastCompany', {
      rules: [
      {
      required: true,
      message: 'Please input your Last Company!',
      whitespace: true,
      },
      ],
      })(<Input placeholder="Present or last Company" />)}
      </FormItem>
      </FormCard>
      </div>
      );
      }
      }
      export default RegisterStepOne;









      share|improve this question














      I am new to reactJS i want to show Error message when someone leave empty filed. Form is already validated but not able to display error message.I Copied this form code from (ant-design) i will share it link to view original form and it working fine but in my form the error message is not working .
      Original Form link Form Link



      My Form Code



      import React from 'react';
      import styled from 'styled-components';
      import 'antd/dist/antd.css';
      import Input from 'antd/lib/input';

      const FormCard = styled.div`
      max-width: 100%;
      overflow: hidden;
      transition: all 0.3s cubic-bezier(0.41, 0.094, 0.54, 0.07) 0s;
      margin-top: 30px;
      `;

      const FormItem = styled.div`
      font-family: 'Chinese Quote', -apple-system, BlinkMacSystemFont, 'Segoe UI',
      'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue',
      Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
      'Segoe UI Symbol';
      font-size: 14px;
      font-variant: tabular-nums;
      color: rgba(0, 0, 0, 0.65);
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      list-style: none;
      margin-bottom: 18px;
      vertical-align: top;
      `;

      class RegisterStepOne extends React.Component {
      render() {
      const { getFieldDecorator } = this.props;
      return (
      <div>
      <FormCard>
      <FormItem label="E-mail">
      {getFieldDecorator('firstName', {
      rules: [
      {
      required: true,
      message: 'Please input your First name!',
      whitespace: true,
      },
      ],
      })(<Input placeholder="First name" />)}
      </FormItem>
      <FormItem label="E-mail">
      {getFieldDecorator('lastName', {
      rules: [
      {
      required: true,
      message: 'Please input your Last name!',
      whitespace: true,
      },
      ],
      })(<Input placeholder="Last name" />)}
      </FormItem>
      <FormItem label="E-mail">
      {getFieldDecorator('email', {
      rules: [
      {
      type: 'email',
      message: 'The input is not valid E-mail!',
      },
      {
      required: true,
      message: 'Please input your E-mail!',
      },
      ],
      })(<Input placeholder="Email" />)}
      </FormItem>

      <FormItem>
      {getFieldDecorator('lastPosition', {
      rules: [
      {
      required: true,
      message: 'Please input your Last Position!',
      whitespace: true,
      },
      ],
      })(<Input placeholder="Present or last position" />)}
      </FormItem>

      <FormItem>
      {getFieldDecorator('lastCompany', {
      rules: [
      {
      required: true,
      message: 'Please input your Last Company!',
      whitespace: true,
      },
      ],
      })(<Input placeholder="Present or last Company" />)}
      </FormItem>
      </FormCard>
      </div>
      );
      }
      }
      export default RegisterStepOne;






      javascript reactjs ant-design-pro






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 24 '18 at 9:16









      Jonas SchemeJonas Scheme

      12




      12
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53456767%2fi-want-to-show-error-message-in-reactjs-form%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53456767%2fi-want-to-show-error-message-in-reactjs-form%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          Refactoring coordinates for Minecraft Pi buildings written in Python