How to Validate the Text Field in JSF

Hi,
I am facing a issue to validate the text field where the below code accepts (space' ',underscore'_',pipe'|') symbol as a first character and last character.Where by it can accept in the middle.
It should not accept special characters also. Below code is working properly for special characters.
<tr>
<td width="30%" align="right"><b><h:outputText id="aAccrualType" value="Accrual Type" /> </b> <span style="color:red">*</span></td>
<td width="50%">: <h:inputText id="accrualType" value="#{accrualTypeMast.accrualType}" required="true" >          
<t:validateRegExpr pattern="^[(a-z)||(A-Z)||(0-9)||(_)||(\s)||(/)]+$" />     
<f:validateLength minimum="1" maximum="50"/>     
</h:inputText>
<h:message for="accrualType" showDetail="true" style="color:red" />
</td>
</tr>
The thing is i dont have much knowledge in regular expression.
Is there any other way to do this.
Could anyone help me in this.
Thanks,
Ambika&#9786;

This has nothing to do with JSF.
I suggest you to read the Pattern API documentation [1]. You can easily create a small Java Application and test the regexp using String#matches() as it uses the same regexp guidelines.
public static void main(String[] args) {
    String regexp = "^[a-z]+$";
    String value = "foo";
    boolean match = value.matches(regexp);
    System.out.println(value + " matches " + regexp + ": " + match);
}[1] http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html

Similar Messages

  • How to populate the TEXT field in MIGO

    Hi folks,
    While creating material document in MIGO or MB01, i am inserting some data in TEXT ( Field in line item level ). This text data is disappearing , once mat doc is created.
    how to populate the TEXT field in MIGO?Is there any cusomisation?it's urgent .
    Regards
    pabi

    Hello Pabitra,
    I had a similar issue in my Project.
    Please verify if the SMOD enhancement MBCF0002 (EXIT_SAPMM07M_001) is active in your system.
    If this is the case, verify from two angles:
    a) Whether the Enhancement was accidentally activated - If yes, then De-activate the same
    b) If there is some logic coded in the User Exit, but, the Text is somehow not determined...even the existing content in the text field (input to EXIT_SAPMM07M_001) will get vanished.
    Hope that your problem will be resolved by this.  Pls reward points.
    With Regards
    Vijay Gajavalli

  • How to validate an text field item using javascript for numbers only.

    hi,
    how to validate an text field item using javascript for numbers only.please help me on this urgent
    please mail me solun if posible on [email protected]

    Hi,
    Page HTML header
    <script>
    function onlyNum(evt) {
      // Usage: onKeyPress="return onlyNum(event)"
      evt = (evt) ? evt : window.event;
      var charCode = (evt.which) ? evt.which : evt.keyCode;
      if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        var status = 'This field accepts numbers only!';
        alert(status);
        return false;
      var status = '';
      return true;
    </script>Item HTML Form Element Attributes
    onKeyPress="return onlyNum(event)"Br,Jari

  • How  to validate the mandatory fields in the view in WDA?

    Dear experts,
                            Iam new to WDA. i just want to know how  to validate the mandatory fields in the view in WDA?please refer any documents for validating the mandatory fields.
    Regards,
    murthy.
    Edited by: Murthy Ganti on Jul 13, 2009 2:31 PM

    Hi,
    Firstly goto view->select the element that you want to make mandatory and set the State property to required.
    Secondly place the below code in the WDDOBEFOREACTION
    DATA: l_view_controller TYPE REF TO if_wd_view_controller.
    * Get view controller
      l_view_controller = wd_this->wd_get_api( ).
    * Check for mandatory attribute
      cl_wd_dynamic_tool=>check_mandatory_attr_on_view(
      EXPORTING view_controller  = l_view_controller
                display_messages = abap_true
    Regards,
    Radhika.

  • How to keep the Text Fields in Nested Subforms together?

    Please find the structure of nested subforms as below:
    --Subform 1
        --Subform 2 {Subform 2 is repeatable}
          Text Field 1
            --Subform 3 {Subform 3 is repeatable}
              Text Field 2
            --Subform 4 {Subform 4 is repeatable}
                  Text Field 3(Header)
                --Subform 5 {Subform 5 is repeatable}
                  Text Field 4(Data) 
    I want to keep the Text Field 2, Text Field 3 and Text Field 4 together.
    I am able to keep the Text Field 3 and Text Field 4 together by checking Keep with next and checking Allow Page Break. But checking Keep with next and checking Allow Page Break for Text Field 2 doesn't help in keeping all the three Text Fields together.
    Can anyone please tell me how do I keep all the three Text Fields (2, 3 & 4) together?
    Please mail me at [email protected] for any solutions. Thanks.

    It would be easier to answer by looking at the form settings.
    You can send the form to [email protected] so I can have a look at it.
    Thanks
    Srini

  • How to disable the text field in File upload element?

    Hi,
    How can we disable the text field in the "File upload" UI element so that the user won't be able to type the file path there, but he will still be able to browse the file using the Browse button?
    Regards
    Praveen

    Hi Praveen,
    This is not possible with the Web Dynpro File Upload UI element.
    Thanks,
    Samta

  • How to validate a text field??

    Can any one tell me hot to validate a text field??
    I want to create a text field which holds alphabets only..

    You can use simple javascript code in the liveChange function such as the following (for sap.m.Input):
    liveChange: function(evt) {
    var inputValue = evt.getSource().getValue();
    this.setValueState(me.validateTagName(inputValue));
            this.validateTagName = function(inputValue) {
        if (inputValue.trim().length < 1) {
        return "Error";
        } else {
        return "None";
    Ran

  • How to enlarge the Text field?

    Hi Gurus,
    Can it possible to enlarge the text field in f-43 screen.Presently the text field is limited with 50 characters,i want it be 75 or 80 characters to display the whole text in print outs of the invoice.If i ask the access key to my basis consultant and change the field to 75 characters(now it is 50) then ll it put impact in any other pragrammes or screens??
    Please suggest.
    Regards,
    Sumeya Offrin

    Hi Sumeya,
    We are not sure, where else the domain(text50) and data element(SGTXT) is being used in SAP. There could be so many objects using this domain. All the objects would be effected, if you change this.
    The side effects of this could be like, when you upgrade your service pack levels or patches, system may throw short dumps or syntax errors. Please take the advise of an ABAPER, before changing the field length.
    Pls go through the below links, which could help you.
    CHANGING STANDARD DOMAIN FIXED VALUES
    Change the SAP field Length
    Re: changing filed length
    Regards,
    Praisty

  • How to make the text fields as mandatory (in 'notes and attachment' tab)?

    Hi,
    We have defined some Fixed Values for texts under IMG>SRM>SRM Server>Cross Application Basic Settings>Text Schema>Define Fixed Values for Texts, for a certain transaction type of RFx responses for a text schema.
    Because of this, the bidder can choose one of these fixed values for texts. This is perfectly working fine.
    Now the question is, we want to make the texts fields as mandatory. i.e. The bidder should not be able to submit the responses if certain texts are blank.
    Is there be any BadI for this?
    GH

    You can use BBP_DOC_CHECK_Badi for this field validation using a filter value RFx/Bid (I ont remember exact word).
    Regards,
    Jagadish.

  • How to resize the text field through the expression?

    It is necessary that another layer was at 150 pixels to the right of the right side of the text field.

    PACK
    Syntax
    PACK source TO destination.
    Effect:
    This statement, which is forbidden in classes, converts the content of the data object source to the data type p of length 16 without decimal places. In contrast to the conversion rules for elementary data types, a decimal separator in source is ignored. This assigns the converted content to the data object destination.
    The data type of source must be character-type, flat, and its content must be interpretable as a numeric value. The data type of destination must be flat. If destination has the data type p, the interim result is assigned to it from left to right. Surplus characters are cut off on the left, and the decimal places are determined by the data type of destination. If destination does not have the data type p, the interim result is converted to the data type of destination according to the rules in the conversion table for source field type p.
    Notes:
    The function of the statement PACK is based on the second half-byte of the code corresponding to a character in most character representations of the BCD representation for the corresponding numeric value. This compilation is generally known as "packing".
    If the source field contains a number without a decimal separator, and the target field has dobj2 of data type p with sufficient length and without decimal places, the result of the PACK statement (which is forbidden in classes) corresponds to the result of the statement MOVE.

  • How to convert the text field into currency field

    Hi,
    I have an requirement to converting the text field into currency.
    If I convert directly it gives dump.
    If I convert this to Numeric means it takes the decimals also as whole value.
    Is there any FM to convert the text field into Currency field.
    Please advice me.
    Thanks in advance.

    Hi,
    I am on an SRM sytem, which unfortunately does not have th FM: PSSV_TEXT_INTO_FIELD_CURRENCY.
    But I also need to transfer a string value like '12,99' to a field with type curr.
    Can i Do that manually, or is there another FM?
    I have already checked code with write to or pack/unpack.
    But without success yet.
    Something like this:
    DATA: g_str(11) type c.
    DATA: g_p type p.
    WRITE '12,99' TO g_str CURRENCY 'EUR'.
    is no use for me. Finally I need to move g_str to my curr-field, which causes st22.
    also: PACK g_str to <curr-field or g_p> dumps.
    Help appreciated.
    regards, matthias

  • How to get the text field in the header for only first page of the report

    Hi,
    I am developing reports in BI Publisher Enterprise where i am facing problem i.e., i have to get some text field in header,for only first page in the result but it is displaying in all the other pages of the report in result.So,please if you have any idea of how to solve it, please reply.It is required as early as possible.
    Thanks in Advance

    Invalid path? What are you doing? Writing the report output to an invalid directory?
    Where are your terms and conditions? It would be very easy just to put them in a database table and select them in your report query.

  • How to change the text field typestyle in InDesign 6 forms

    I am designing a form in Indesign CS6. I would like to change the typestyle in my text fields. It seems to default to Times Roman. I want to change it to Ariel. Any suggestions on how to do this. I do not want to have to do it in Acrobat.

    You can't do that in InDesign, unfortunately, so you'll have to make changes in Acrobat after exporting to PDF. With scripting you have the opportunity to automate this. Post again if you'd like more info.
    Also, I would strongly advise against using Arial and use the built-in Helvetica instead. Acrobat/Reader actually use a version of Arial when Helvetica is specified. If you specify Arial, it will embed the entire font, resulting in a sigificant and unnecessary increase in file size.

  • How to calcaulate the text field data

    hi frnds need help,
    how to find difference bet time if i taking  the data  from texts fields data i.e long text
    i called the FM & passed the parameters
    of text data but iam gettin answer as zero
    i hope ur gettin my point

    Hi
    You have to use READ_TEXT fun Module to fetch the Long text data by passing the correct paramters like OBJECT,ID,OBJECTNAME and LANGuage fields
    see the doc
    READ_TEXT
    READ_TEXT provides a text for the application program in the specified work areas.
    The function module reads the desired text from the text file, the text memory, or the archive. You must fully specify the text using OBJECT, NAME, ID, and LANGUAGE. An internal work area can hold only one text; therefore, generic specifications are not allowed with these options.
    After successful reading, the system places header information and text lines into the work areas specified with HEADER and LINES.
    If a reference text is used, SAPscript automatically processes the reference chain and provides the text lines found in the text at the end of the chain. If an error occurs, the system leaves the function module and triggers the exception REFERENCE_CHECK.
    Function call:
    CALL FUNCTION 'READ_TEXT'
    EXPORTING CLIENT = SY-MANDT
    OBJECT = ?...
    NAME = ?...
    ID = ?...
    LANGUAGE = ?...
    ARCHIVE_HANDLE = 0
    IMPORTING HEADER =
    TABLES LINES = ?...
    EXCEPTIONS ID =
    LANGUAGE =
    NAME =
    NOT_FOUND =
    OBJECT =
    REFERENCE_CHECK =
    WRONG_ACCESS_TO_ARCHIVE =
    Export parameters:
    CLIENT
    Specify the client under which the text is stored. If you omit this parameter, the system uses the current client as default.
    Reference field: SY-MANDT
    Default value: SY-MANDT
    OBJECT
    Enter the name of the text object to which the text is allocated. Table TTXOB contains the valid objects.
    Reference field: THEAD-TDOBJECT
    NAME
    Enter the name of the text module. The name may be up to 70 characters long. Its internal structure depends on the text object used.
    Reference field: THEAD-TDNAME
    ID
    Enter the text ID of the text module. Table TTXID contains the valid text IDs, depending on the text object.
    Reference field: THEAD-TDID
    LANGUAGE
    Enter the language key of the text module. The system accepts only languages that are defined in table T002.
    Reference field: THEAD-TDSPRAS
    ARCHIVE_HANDLE
    If you want to read the text from the archive, you must enter a handle here. The system uses it to access the archive. You can create the handle using the function module ACHIVE_OPEN_FOR_READ.
    The value '0' indicates that you do not want to read the text from the archive.
    Reference field: SY-TABIX
    Default value: 0
    Import parameters:
    HEADER
    If the system finds the desired text, it returns the text header in this parameter.
    Structure: THEAD
    Table parameters:
    LINES
    The table contains all text lines that belong to the text read.
    Structure: TLINE
    Exceptions:
    ID
    The text ID specified in the parameter ID does not exist in table TTXID. It must be defined there together with the object of the text module.
    LANGUAGE
    The parameter LANGUAGE contains a language key that does not exist in table T002.
    NAME
    The parameter NAME contains the name of a text module that does not correspond to the SAPscript conventions.
    Possible errors:
    The field contains only blanks.
    The field contains the invalid characters ‘*’ or ‘,’.
    OBJECT
    The parameter OBJECT contains the name of a text object that does not exist in table TTXOB.
    NOT_FOUND
    The system did not find the specified text module.
    REFERENCE_CHECK
    The text module to be read has no text lines of its own but refers to the lines of another text module. This reference chain can include several levels. For the current text, the chain is interrupted, that is, one of the text modules referred to in the chain no longer exists.
    WRONG_ACCESS_ TO_ARCHIVE
    The exception WRONG_ACCESS_TO_ARCHIVE is triggered if an archive is accessed using an incorrect or non-existing archive handle or an incorrect mode (that is, read if the archive is open for writing or vice versa).
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • How to validate the input field

    Hi,
    I have a input form which is draged from input port of a RFC.
    in this input form i have two input fields nad submit button.
    on of this input field should always take the character values only. it should not take any numeric value
    and other input field should always take numeric value only.
    i.e how to validate this two input fields.
    regards
    srinivas

    Hi,
    U can validate input fields using javascript.Write OnClientClick function for that submit button if ur using htmlb or onClick if u r using html.Refer the follows
    http://help.sap.com/saphelp_nw70/helpdata/en/03/900e41a346ef6fe10000000a1550b0/frameset.htm
    There are two ways to achieve ur task.
    1.By checking for all alphabets.in this u need check all the alphabetic characters one by one.Refer the following
    http://www.shiningstar.net/articles/articles/javascript/javascriptvalidations.asp?ID=ROLLA
    http://www.shiningstar.net/articles/articles/javascript/checkNumeric.asp?ID=AW
    2.By using regular expressions.its very easy and a single line code.here u need to specify single expression for whole alphabets.Refer this
    http://aspzone.com/blogs/john/articles/173.aspx
    Everything has been given for validating in javascript.i hope u also validating in javascript only.
    For more details on "Regular expressions" search google.
    Regards,
    Tamil K

Maybe you are looking for

  • Help with multiple ipods with itunes

    hello -- We have 3 ipods in this house -- ipod nano and two shuffles - i have tried to set up an account for the ipod shuffles but the music goes to my library and will not download ontto the shuffles, which belong to my children -- any help would be

  • 3D composition opacity

    As I am building up this project of mine, I have added  a pre-comp that includes a neon sign and a brick wall. Regardless of the stacking order in the layers panel and timeline and regardless of their respective positions in the 3D space (I've tried

  • WSAECONNREFUSED: Connection refused

    i am trying to access my newly installed system after i have performed a client copy and it gives the following error partner not reached (host 192.167.1.3, service sapdp03) WSAECONNREFUSED: Connection refused here is the detailed error log Time:    

  • Printing PDF documnet

    Hi All I have created customised program to gather list of documents  (Document info records DIR) attached to material master of components in BOM. There is provision to print originals from reports. When i press print button then it prints word or e

  • I need snow leopard for macbook pro early 2011

    broke my disck original. I have Lion but i need return a snow leopar. I have retail snow leopard 10.6.3 but does not work. Reading. I have read que i need snow leopar for macbook pro 13 early 2011 especific