Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Having issues with validation code

 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is the validation code, but it is not working.I am not sure where I am going wrong in this?



 
Nikhil Padharia
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Replace "User-ID" name of textfield to "UserID".
- in the name creates problem parsing javascript.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18156
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the first place you went wrong was when you decided to write your own login instead of using the J2EE standard security system. Do-it-Yourself security systems are horribly insecure. In all the years I've worked with J2EE, I've never run across one that couldn't be cracked in fairly short order.

However, your more immediate problem is that you forgot to return "true" from your validation Javascript.
 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:Well, the first place you went wrong was when you decided to write your own login instead of using the J2EE standard security system. Do-it-Yourself security systems are horribly insecure. In all the years I've worked with J2EE, I've never run across one that couldn't be cracked in fairly short order.

However, your more immediate problem is that you forgot to return "true" from your validation Javascript.



Dear Tim,

Yes I know its insecure I just want to do something from Scratch... from start... and be like you people a JavaGuru :)
 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also facing issue in one other code



Not sure where i am going wrong
 
Palak Mathur
Ranch Hand
Posts: 342
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vishal,

When you are using Javascript, and want to traverse to the element using the format , then it is better not to include hyphen ('-"). In its place, it is better always to use an underscore("_") or better still to join the words like("userID").

Moreover, I would recommend you to add an attribute "id" to the element. like . In this case you can use the following:
and this will work absolutely fine.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64835
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Palak Mathur wrote:
When you are using Javascript, and want to traverse to the element using the format ,

Nope. That's an antiquated format that has lots of problems. Use document.getElementById() or one of the other locator methods. Or use a library such as jQuery.

Moreover, I would recommend you to add an attribute "id" to the element. like . In this case you can use the following:
and this will work absolutely fine.

This is a better suggestion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic