title: Validating an email in native script code
body: <p>I am using an if statement to validate an email however when I add it in the native script playground it says function can only be declared at top level or inside a block. So I'm unsure where to add this code. </p>
  
  <pre><code>&lt;template&gt;
  &lt;Page&gt;
      &lt;ActionBar title="authentication" /&gt;
          &lt;StackLayout id="registervalidate" class="registervalidate"&gt;
              &lt;TextField v-model="youremail" class="youremail"&gt;&lt;/TextField&gt;
              &lt;TextField v-model="yourpassword" class="yourpassword"&gt;&lt;/TextField&gt;
              &lt;Button text="submit" @tap="onSubmit" /&gt;
          &lt;/StackLayout&gt;
    &lt;/Page&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
  export default{
  data(){
  return{
  yourmail:'',
      yourpassword:''
   } 
   },
    methods: {
      onSubmit: function() {
              if (!this.youremail) {
                   } else if (!this.validEmail(this.youremail)) { 
  //CHECK IF EMAIL IS VALID
  
                     return;
              }
              if (!this.yourpassword) {
                  return;
              } else {
                  return;
              }
  
    validEmail: function(email) {   // valid email 
    var re = /^(([^&lt;&gt;()\[\]\\.,;:\s@"]+(\.[^&lt;&gt;()\[\]\\.,;:\s@"]+)*)|(".+"))@((\ 
    [[0-9]{1,3}\.[0-9] 
    {1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
  
  }
  
  &lt;/script&gt;
  </code></pre>