2016-04-20 47 views
-4

こんにちは私はアプリケーションでグランツを実装していますが、コントローラが定義されていないというエラーが発生しています。私は試してみましたが、解決策が見つかりませんでした。この問題を解決するのを手伝ってください。はGrunt.jsを使用して定義されていません

commonModule.exports = function(grunt) {grunt.initConfig({ 
pkg: grunt.file.readJSON('package.json'),});grunt.loadNpmTasks('grunt-contrib-jshint');grunt.loadNpmTasks('grunt-contrib-concat');grunt.loadNpmTasks('grunt-contrib-uglify');grunt.loadNpmTasks('grunt-ng-annotate'); grunt.registerTask('test'['jshint','ngAnnotate','concat','uglify']);ngAnnotate: { 
options: { 
    singleQuotes: true 
}app: { 
    files: { 
        'login/js/login-controller.js', 
     } 
}}concat: { 
js: { //target 
    src: ['login/js/login-controller.js'], 
    'login/js/login-controller.js', 
}}}; 
+0

が最初でregexe(検索を使用するよりも、メールや数に文字列を分割でありますインターネット)とテストを使用して(ブール値を返す)鉱石のマッチ(リターンマッチ)。電子メールのregExeは非常にハードコアです。あなたは自分でそれを書くことができますが、私はしません。 – TEST

+0

フィドルコードと固定された文法とフォーマットが追加されました – Raghuveer

+0

一度私のフィドルをご覧ください – chaitanya

答えて

0

ここでは、電子メールと電話番号の両方を検証する簡単なjavascriptコードを示します。

<html> 
<head> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> 
<script> 
function ValidateEmail(mail) 
{ 
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; 
// if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailAddr.value)) 
if(mail.match(mailformat)) 
    { alert(mail); 
    return (true) 
    } 
    alert("You have entered an invalid email address!") 
    return (false) 
} 

function validate() 
{ 
var data=document.getElementById("email").value; 
checkNumberorEmail(); 

} 
function phonenumber(inputtxt) 
{ 
    var phoneno = /^\d{10}$/; 
    if((inputtxt.match(phoneno))) 
     { 
     alert(inputtxt); 
     return true; 
     } 
     else 
     { 
     alert("enter 10 digit number"); 
     return false; 
     } 
} 


function checkNumberorEmail() 
{ 
    var data=document.getElementById("email").value; 
    if (isNaN(data)) 
    { 
    ValidateEmail(data) ; 

    } 
    else{ 
    phonenumber(data) 
    } 
} 
</script> 
</head> 
<body> 

<form > 

<input type="text" name="email" id="email"> 
<input type="button" onclick="validate()"> 
</form> 
</body> 
</html> 

FIDDLE

0

方法自体は良くありません。しかし、ここで、角度のjsで可能な簡単な関数

HTML

<form name="form" ng-app="app" ng-controller="Ctrl" > 
<div class="control-group" ng-class="{invalidClass: 'error'}[submitted && form.email.$invalid]"> 
    <label class="control-label" for="email">Your email address/Mobile number</label> 
    <div class="controls"> 
     <input type="text" name="email" ng-model="email" required /> 

    </div> 
</div> 

<button type="submit" class="btn btn-primary btn-large" ng-click="submitForm()">Submit</button></form> 

コントローラ

$scope.submitForm = function(){ 
if(validateEmail($scope.email) || validateMobile($scope.email)){ 
// The nput is email or mobile 
} 
else{ 
    //both are not valid 
    console.log("Invalid inputs"); 
    $scope.invalidClass = true; 
} 
} 

function validateEmail(email) { 
    var re = /^(([^<>()[\]\\.,;:\[email protected]\"]+(\.[^<>()[\]\\.,;:\[email protected]\"]+)*)|(\".+\"))@((\[[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); 
    } 
function validateMobile(email) { 
    var re = /^\d{10}$/; 
    return re.test(email); 
} 
+0

@chaitanyaなぜ4ヶ月後に受け入れを変更しましたか? –

関連する問題