I am trying to pass an alert after the user submits a form. The html is like this
<form id="profile" name="profile">
<label for="firstName">Male</label>
<input type="text" name="firstname" id="firstName" maxlength="20" class="required" value=""/>
<input type="submit" name="sumit" value="submit"/>
</form>
And the JS is
var Form = function(){};
Form.prototype.formValidate = function($form){
$form.on('submit', function(e){
e.preventDefault();
this.test()// this doesn't work
//alert('t') // this works
})
}
Form.prototype.test = function(){
alert('t');
}
var form = new Form();
form.formValidate($('#profile'))
When I am getting an error saying ..this.test is not a function... If I just pass the alert right after the e.preventDefault() but it cant call I cant call a method by a keyword 'this'. Which makes me say my scope is not right. What am I missing?