-
1. clear dashes onBlur
ilya40umov Jan 20, 2011 1:09 PM (in response to akabir77)1) These are a lot of scripts here, take look at this link:
http://lawrence.ecorp.net/inet/samples/regexp-format.php
IThis is a piece of this page:
Removing Formatting from Phone and SSNhttp://lawrence.ecorp.net/inet/samples/regexp-format.php#top
Phone Numbers and Social Security Numbers are customarily written with separator characters. In a variety of situations these need to be removed for processing or storage in a database. This next regular expression will remove parenthesis, periods, dashes, and white space.
Enter numbers with any of the customary separators and they'll be stripped out.
Just one regular expession was used that had a set of characters to be replace, and the global flag. Two options are shown below: itemizing characters to be removed or removing any non-digit. This example uses the first option.
Itemize characters to remove function cleanString (str) { return str.replace(/[\(\)\.\-\s,]/g, ""); } Remove all non-digits function cleanString (str) { return str.replace(/[^\d]/g, ""); }
2) Try to use jQuery, onblur event and selectors
http://livedemo.exadel.com/richfaces-demo/richfaces/jQuery.jsf
-
2. Re: clear dashes onBlur
akabir77 Jan 20, 2011 1:35 PM (in response to ilya40umov)thanks for the reply. unfortunately my office has a block on the first link.
I need to figure out how to get the value out from the element in java script.
can you tell me what i need to do in the java script so that it gets the value out. currently its not recognizing the ssn.
Also the example that you posted here with the text box and button is not working...
-
3. clear dashes onBlur
ilya40umov Jan 20, 2011 1:36 PM (in response to akabir77)The simples way is described here:
https://developer.mozilla.org/en/DOM/document.getElementByID
http://bytes.com/topic/javascript/answers/92516-getelementbyid-value
But you should be careful because your element ID will be the following:
formId:elementId
Look at this for some details about ids:
http://illegalargumentexception.blogspot.com/2009/02/jsf-working-with-component-ids.html
So the better way is to use #{rich:component('id')} function.
P.S. Use firebug to browse DOM tree. It helps a lot.
-
4. clear dashes onBlur
boy18nj Jan 20, 2011 5:07 PM (in response to akabir77)Hi Kabir,
This is how you get the value-
onblur="alert(this.value.replace(/-/g, ''));"
Make sure after you update the value, you need to rerender your inputText.
-
5. clear dashes onBlur
ilya40umov Jan 20, 2011 5:16 PM (in response to boy18nj)>>Aman S
Are you sure that he needs to rerender inputText? I suppose that data will be lost in this case. This changes are to be done only in DOM tree and they are not going to be applied to the server side(The data on a server is updated only be submit or if a4j:support is added to a tag).
-
6. clear dashes onBlur
boy18nj Jan 20, 2011 9:28 PM (in response to ilya40umov)Illya,
So what you are saying is use a4j:support tag to submit value to the server and then rerender inputText?
-
7. clear dashes onBlur
ilya40umov Jan 21, 2011 12:09 AM (in response to boy18nj)No. It means that he possibly may need a4j:support. But in general he does not need to rerender inputText. Because he works only with DOM on the client side and the value server is not changed.
-
8. clear dashes onBlur
boy18nj Jan 21, 2011 1:48 PM (in response to ilya40umov)Hi Kabir,
Try this code, I have tested on my side and it works....
onblur="this.value = this.value.replace(/-/g, '');"
-
9. clear dashes onBlur
akabir77 Jan 24, 2011 8:52 AM (in response to boy18nj)Thanks Aman S that solution worked for me.
Thanks every one for your valuable comments.