Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8635

Re: Email validation of a simple form

$
0
0

Hi ,

 

in view put this code

 

<Label text="Email" />

      <Input

        id="emailInput"

        type="Email"

        class="sapUiSmallMarginBottom"

        placeholder="Enter Email ..."

        change="validate"

         />

 

 

in controller.js put below code

 

validate:function()

  {

  var email = this.getView().byId("emailInput").getValue();

  var mailregex = /^\w+[\w-+\.]*\@\w+([-\.]\w+)*\.[a-zA-Z]{2,}$/;

    if (!mailregex.test(email)) {

      alert(email + " is not a valid email address");

this.getView().byId("emailInput").setValueState(sap.ui.core.ValueState.Error);

        }

  },

 

 

its working in my system i think you will also get it.


Viewing all articles
Browse latest Browse all 8635

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>