Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello
I am new to AngularJS, I have some text boxes, and I want to validate them using Angular. for "email" text box, I have done it, so if user enter a wrong email pattern, the border box of email text box will get into red, but for "password" text boxe, it will not work.and for "Phone" text box, I need to prevent user to enter characters. I mean he/she entered a character, it will not being displayed in text box.can you help me please?
here is my code:
jsfiddle.net

What I have tried:

here is my code and what I have tried: jsfiddle.net
Posted
Updated 10-Jul-17 1:11am
v5

1 solution

There is so much wrong there.

First off, all your functions are wrong. You define your scope function as empty, then redefine the controller function in angular (at least that's the effect in my browser using the referenced scripts in your jsfiddle).

look:
JavaScript
//app.controller("myCtrl",function($scope)){
//...
//}
app.controller("myCtrl",function($scope){
//...
});


Your phonenumber keybinding is the same, but the function that sets it up is never run anyway.

You don't set the controller or app in your div, either

Look, just examine this. It's mostly fixed but I didn't spend much time

Form validation - AngularJS - JSFiddle[^]
 
Share this answer
 
Comments
Ali Majed HA 10-Jul-17 9:20am    
Thanks a lot, It was great.
Andy Lanng 10-Jul-17 9:27am    
Oh good. I was worried I sounded a bit flippant. I'm glad it helped :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900