aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Delete A Part of Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Delete A Part of "," seperated Text Box " Watch "Delete A Part of "," seperated Text Box " New topic
Author

Delete A Part of "," seperated Text Box

Sam Pablo
Greenhorn

Joined: Apr 08, 2010
Posts: 18

Hi Folks,

Hope you guys are doing well.

My text box takes multiple names and the employee id as input with "," seperating them. If the user tries to delete any character/number from those details, the text field should be cleared.

I have achieved the task of clearing the whole text box if the user hits backspace or delete button (works fine with single name entry )

N w that I have multiple names, I only want to delete the only name and its corresponding employee id text; leaving the rest of the text in the box intact.

Any idea to accomplish the same would be great.


Thanks,

Sud.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Your mystery code would be?

Eric
Sam Pablo
Greenhorn

Joined: Apr 08, 2010
Posts: 18



This piece of code accomplishes the above stated reqirement of clearing the textfield. Now I want to delete a part of the text in the text field:

e.g. Sudipto Shekhar (ID2345), Jerrki (ID9301)

If the user tries to delete any character from Jerrki (ID9301) or Sudipto Shekhar (ID2345) , I want to delete the particular name & id group, leaving the other part of the text intact.

I do not need any written code,just a hint on the trick to solve this and the javascript functions that can be used would be fine.

Thank you Eric for showing interest in the post...
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

I do not need any written code,just a hint on the trick to solve this and the javascript functions that can be used would be fine.

My hint would be, find the last comma and only keep the text up to that comma.
But what if I'm typing a name and I type seap instead of sean, I hit backspace and get annoyed because I have to type it all in again, you should be careful when changing default behaviour of things, especially when people are used to these.

Sean


I love this place!
David Johnson
Greenhorn

Joined: Oct 13, 2003
Posts: 4
I am having trouble giving a hint because I don't understand the purpose.

Is the reason for deletion of the entire field on backspace or delete convenience for the user or data preservation?

Either way, there is an expected behavior in text boxes. Changing the expected behavior may not enhance the user experience, as noted in the typo comment above.

Please explain!
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

I read your post again and I think I may have misunderstood your requirements:
I only want to delete the only name and its corresponding employee id text; leaving the rest of the text in the box intact.
I'm not sure what this line means.
Perhaps you could show your HTML code with the inputs on it as well?
You haven't mentioned the ID text in anything you have posted.
Sean
Sam Pablo
Greenhorn

Joined: Apr 08, 2010
Posts: 18

I am sorry not provide you guys the details.

Ok, so here it is. I have the following text in my text box:

Sudipto Shekhar (ID2345), Jerrki (ID9301), Sam Pablo(ID1002)

I want these data to be saved in the database. Now, as the data in the textbox is fetched from the database, the user is not supposed to delete any details from the one that is present in the textbox. What I mean is I cannot change Sudipto Shekhar (ID2345) to Sudipto Shekhar (ID2346). And so, if the user tries to change anything from the text, I want to delete the whole text. For example:

Sudipto Shekhar (ID2345), Jerrki (ID9301), Sam Pablo(ID1002). If the user tries to change Sudipto Shekhar (ID2345) to Sudipto Shekhar (ID2346) and hit a backspace or delete button, I want to delete entire Sudipto Shekhar (ID2345), but just that, and want to retain rest of the text in the text box:

Jerrki (ID9301), Sam Pablo(ID1002)

A better example would be how the outlook To: textbox.

I hope I am clear now. Please let me know if I am still not clear.
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

In my opinion I think you have gone the wrong way about this, there are a few ways that people can get around this that it makes it almost a pointless exercise to try.
For example I could turn javascript off in my browser which would prevent your delete/backspace function working.
I could modify the javascript on the page using a tool such as greasemonkey and change as I wish.
Lastly what is to stop me simply clicking in the middle of the ID and changing it, e.g. change Sam Pablo(ID1002) to Sam Pablo(ID109902).

I have a feeling that to do something like outlook it will be a bit more complicated.

Even gmail doesn't do anything like that, however if you look at hotmail, that would be exactly what you want to do.

Sean



Sam Pablo
Greenhorn

Joined: Apr 08, 2010
Posts: 18

Hey Sean,

Thanks for your thoughts but I am more interested in getting this done as I know that the organization for which I am developing this does not recommend to turn off javascript! also, this same technique is used at lots of pages.

Any ways, thanks for your time
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Delete A Part of "," seperated Text Box