$scope.myCode=function(dynamicField){
    console.log("exchangeRate Validator Called");
    var regex=new RegExp("^[0-9]*\.?[0-9]{0,6}$");
    var regexCornerCase=new RegExp("^[0-9]+\.$"); //if this matches, 
    //then input has an isuue
    if(isNaN(dynamicField.value)){
        alert("This value accepts only numbers1");
        dynamicField.value=null;
        return;
    }else{
        console.log(regex);
        if(regex.test(dynamicField.value)){
            if(regexCornerCase.test(dynamicField.value))
            {
                console.log(regexCornerCase);
                alert(dynamicField.value);
                alert("This field accepts only numbers2");
                dynamicField.value=null;
                return;
            }
        }
        else{
            alert("This field accepts only numbers");
            dynamicField.value=null;
        }
    }
};
My Use case:
- the required dynamicField.valueshould not be like '11111.' or '.'.
- My current regex: ^[0-9]+\.$does not seem to work well for this.
- The online regex engines were matching this correctly, but in javascript it didn't.
 
    