AngularJS: Prevent form submission or stop page refresh on submit

I have recently started learning AngularJS and came across form that would refresh every time I click the submit button. So, here are a couple of ways to prevent that from happening.


<div ng-app="my-app">
  <div ng-controller="myFormController">
    <form action="test_submit.php" method="post" accept-charset="utf-8" name="myTestForm" ng-submit="myTestForm.$valid && submit()" novalidate>
        <label for="fname">First Name</label>
        <input type="text" ng-model="dataForm.fname" name="fname" id="fname" required>

        <label for="lname">Last Name</label>
        <input type="text" ng-model="dataForm.lname" name="lname" id="lname" required>

        <label for="email">Email</label>
        <input type="text" ng-model="" name="email" id="email" required>

        <button name="submit" ng-disabled="myTestForm.$invalid" type="submit">Submit</button>

Angular JS

var myApp = angular.module('my-app', []);

myApp.controller('myFormController', function($scope, $http) {
  $scope.dataForm = {};

  $scope.submit = function() {
    // Ajax

Continue reading “AngularJS: Prevent form submission or stop page refresh on submit”

Validating an email via JavaScript

Nearly every programmer needs to validate email id somewhere sometime while development. Here I have got a simple regex that is very good at validating JavaScript.



Continue reading “Validating an email via JavaScript”

HACKERTEST.NET | Level 6: Linking javascript

Tired of prompts? Lets solve this one quickly and move to next mission. When you check the source code for his mission you will not find a function like the previous levels. It is because the we necessarily do not need to write the javascript codes in our main file. We can also write it in a separate js file and link it.

<SCRIPT SRC="psswd.js" LANGUAGE="JavaScript" type="text/javascript"></script>

Like its done here. The javascript function is written in a separate psswd.js file. So lets just open this file using directory traversal and move on.

Continue reading “HACKERTEST.NET | Level 6: Linking javascript”


After solving the previous levels with javascript prompt level 5 isn’t difficult to solve. Some of you might face problems in it because if you click cancel the page redirects itself, giving you no time to check out the source code.

But if you are using Firefox (no idea about other browsers) you can still check the source code by pressing ctrl+U while the page is loading. Just open the source code and you’ll get the answer.

var pass, i;
pass=prompt("Password: ","");
if (pass=="SAvE-as hELpS a lOt") {
}else {alert("Try again");

The password is SAvE-as hELpS a lOt.

Continue reading “HACKERTEST.NET | Level 5: SAvE-as”