React form Action

Source: Internet
Author: User

 var MyForm = React.createclass ({getinitialstate:function () {return {email: "", Intro: "",    City: "Hz", male:true,//Gender Emailerror: "", Introerror: ""};      }, Handleemail:function (e) {var value = E.target.value;      var error = '; if (! ( /^[a-za-z0-9.! #$%& ' *+\/=?^_ ' {|} ~-][email protected][a-za-z0-9] (?: [a-za-z0-9-]{0,61}[a-za-z0-9])? (?:\. [A-za-z0-9] (?: [a-za-z0-9-]{0,61}[a-za-z0-9])?)      *$/.test (value)) {error = ' Please enter the correct email ';    } this.setstate ({email:value, emailerror:error});      }, Handleintro:function (e) {var value = E.target.value;      var error = "";      if (Value.length <) {Error = "Introduction cannot be less than 10 words";    } this.setstate ({intro:value, introerror:error});      }, Handlecity:function (e) {var value = E.target.value;    This.setstate ({city:value,}); }, Handlegender:function (e) {var mAle =!!      (E.target.value = = ' MALE ');    This.setstate ({male:male}); }, Render:function () {return (<div> <p> <label htmlfor= ' email ' >email:& lt;/label> <input type= ' text ' name= ' intro ' id= ' intro ' Value={this.state.email} Onchange={this.handleemail} /> <span>{this.state.emailError}</span> </p> <p> <label html For= ' intro ' >intro:</label> <textarea type= ' text ' name= ' intro ' id= ' intro ' Value={this.state.intro} OnC Hange={this.handleintro}/> <span>{this.state.introError}</span> </p> <p&gt          ; <label htmlfor= ' city ' > location:</label> <select name= ' town ' id= ' Cities ' value={this.state.city} Onchang e={this.handlecity}> <option value= ' Hz ' > Hangzhou </option> <option value= ' bj ' > Beijing </o ption> <option value= ' sh ' > Shanghai</option> </select> </p> <p> <label> gender:</label>          <input type= ' Radio ' name= ' Gender ' Checked={this.state.male} Onchange={this.handlegender} value= ' Male '/>        <input type= ' Radio ' name= ' Gender ' Checked={!this.state.male} Onchange={this.handlegender} value= ' FEMALE '/>  </p> </div>)}); React.render (<myform/>, document.getElementById ("Div1"));

React form Action

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.