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

Similar Messages

  • 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 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

  • How to validate empty Text Field?

    Hi,
    I am Thirupathi,
    I am new to JSF. I am able to validate the value of a component which has some value using attribute
    validator="#{UserNumberBean.validate}"
    in this case it is calling validate method of UserNumberBean.
    but if i keep the field empty then it is not calling that validate method of UserNumberBean.
    Please can any one clarify my doubt.
    wait for reply
    Thanx in advance.
    Thirupathi Reddy
    mail Id: [email protected]

    validate method is called to validate the correctness of the value input by user (eg. email format, phone numebr etc.). If user leaves the input box empty then there is nothing to validate and so validate is not called.
    If you want customised messages for required fields you can use requiredMessage attribute in your inputText tag provide that you are using JSF1.2. It is not available in JSF1.1. In JSF1.1 it is requires some extra coding. You can do like this :
    In your managed bean
    public class MyBean {
        private String userName = "";
        private String password = "";
        private ArrayList errors = new ArrayList();
        public String getErrors() {
            String message;
            if (errors.size() == 0) {
                message = "";
            } else {
                message = "<FONT COLOR=RED><UL>\n";
                for(int i=0; i<errors.size(); i++) {
                    message = message + "<LI>" +
                            (String)errors.get(i) + "\n";
                message = message + "</UL></FONT>\n";
            return(message);
        public String validateUser() {
            errors.clear();
            if (userName  == null || userName.trim().length() == 0) {
                errors.add("User Name is required");
            if (password == null || password.trim().length() == 0) {
                errors.add("password is required");
            if (errors.size() > 0) {
                return(null);
            } else {
               //perform your logic here
               return("returnString");
    }In your jsp page, include the errors tag as below. It will show all errors on top of the page.
    <f:view>
            <h:form>
                <h:outputText value="#{MyBean.errors}" escape="false"/>
                <p>User Name: <h:inputText value="#{MyBean.userName}" /></p>
                <p>Password: <h:inputText value="#{UserBean.password}" /></p>
                <h:commandButton value="Login" action="#{UserBean.validateUser}" />
            </h:form>
        </f:view>One point to remember is to clear the errors List in every action.
    Hope it helps.
    -Hitesh

  • How to add new text field in standard report

    how to add new text field in standard report?

    Hi,
    I presume you are talking about a report display in ALV and u wish to add a column to it .
    If it is a global requirement ,as in table being used there in ALV can be modified, then you can append the table and the system should pick up the same automatically from there.
    Otherwise , you can make a Z program . Modify the catalog being used in ALV.
    Regards,
    Shweta

  • 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 collapse unused text field in PDF form

    Hi all, may i know how to collapse unused text field in a PDF form. Etc, we have alot of description line for user to enter the info, but some line will be left unused, so i was wondering whether can i hide those unused text field. But when i need them, i just expand it and use it.

    I don't think w/o UI Customization it is possible.
    UI customization won't be a small one as it is a common wizard and used at multiple places. So it will be a huge work.

  • 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.

  • In Layout screen, how to validate  i/p field?

    hi,
    in Layout screen at se51, how to validate  i/p field?
    Regards,
    bb.
    Edited by: BBR on Jul 24, 2008 4:23 PM

    Hi
    if u want to validate the screen fields in Module pool programming  then u need to go for
    CHAIN & ENDCHAIN.
    Following is the example which guide u to use the chain and endchain:
    In the flow logic of ur screen before the module write this code
    CHAIN.
    FIELD TABNAME-FIELDNAME(OR SCREEN FIELD NAME).
    MODULE MODULENAME(OR FIELD NAME).
    ENDCHAIN.
    Double click on the module name and write ur validations.
    <removed_by_moderator>
    Regards
    Chandu
    Edited by: Julius Bussche on Aug 6, 2008 1:44 PM

  • How to rotate a Text Field?

    Is there anyone who knows how to rotate a Text Field? I just need to move some degrees (for example: clockwise).
    Thanks in advance for any help you can provide

    You can onlt rotate it in 90 degree imcrements ...this is controlled on the
    layout tab next to the anchor setting.
    Paul

  • How to make a text field required at run time when the user clicks the checkbox ?

    I got a form where , there are several checkboxes and text fields associated with that checkboxes.If the use clicks on the check box then the associated
    text fields should become required.I have tried the change event and the click event for the checkboxes.It gives error in the onChnage event and I got some weird results in the on click event .Sometimes if the user click the check box , then for the 1st time the field doesnt become required , then the user onclicks the check box and when the user clicks the checkbox for the second time the field becomes required,but if i deselects the highlighted field option and selects it again the field becomes required even if the user onchecks it I am totally confused !!! Adding to it i have also written the wrong code still i achieved the desired result ?? How it can be possible . I am writing the codes below , please help me as i am working under a deadline from the client.
    onChange event :
    var newVal = this.boundItem(xfa.event.newText);
    if(newVal == 0)
        xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.Purchasecost3_1" ).validate.nullTest = "disabled";
      else
         xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.Purchasecost3_1" ).validate.nullTest = "error";
    For the onClick event :
    var a = xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row2.CostItemRecovere d_OnlyEnergyCharges").rawValue;
    //app.alert(a);
    if(a == 0)
        xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck_ L1_1").validate.nullTest = "error";
      if(a == 1)
          xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck_ L1_1").validate.nullTest = "disabled";
       Please help someone !!!

    I used the onchange event and wrote the code for it. I got the result . But there is a problem.All these fields are in a table and it's a dynamic table where you can add rows dynamically at the run time .I have other change event for some fields in this table .All are working fine when i add the row.But for this check box the required fields are not validated as required at the run time . I am here giving the code , Please help me .
    form1.Subform0.Subform1.Subform9.Subform10.Table48.Row2.CostItemRecovered_OnlyEnergyCharge s::change - (JavaScript, client)
    if(this.rawValue == "1")
      xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck_ L1_1").mandatory= "error";
      xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck_ L2_1").mandatory= "error";
      xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row5.ComplianceCheck_ L1_2").mandatory= "error";
      xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row5.ComplianceCheck_ L2_2").mandatory= "error";
      xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row6.ComplianceCheck_ L1_3").mandatory= "error";
      xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row6.ComplianceCheck_ L2_3").mandatory= "error";
      xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row7.ComplianceCheck_ L1_4").mandatory= "error";
      xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row7.ComplianceCheck_ L2_4").mandatory= "error";
      xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row8.ComplianceCheck_ L1_5").mandatory= "error";
      xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row8.ComplianceCheck_ L2_5").mandatory= "error";
    else
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck_ L1_1").mandator = "disabled";
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck_ L2_1").mandatory = "disabled";
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row5.ComplianceCheck_ L1_2").mandatory = "disabled";
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row5.ComplianceCheck_ L2_2").mandatory = "disabled";
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row6.ComplianceCheck_ L1_3").mandatory = "disabled";
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row6.ComplianceCheck_ L2_3").mandatory = "disabled";
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row7.ComplianceCheck_ L1_4").mandatory = "disabled";
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row7.ComplianceCheck_ L2_4").mandatory = "disabled";
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row8.ComplianceCheck_ L1_5").mandatory = "disabled";
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row8.ComplianceCheck_ L2_5").mandatory = "disabled";

  • How to autopopulate a text field with unique data from multiple data sets

    Hi,
    I'm a laboratory manager in charge of a hospital project which will be using pdf forms to send and receive data from our end users across the city. I need help with the last part of our pdf form, specifically with a js that will do a bit of text-field autopopulation magic. This, unfortunately, is a beyond what I have taught myself about pdf js functionality.a
    The problem:
    I need to provide my end users with a text field containing a set of data [A, B, C, D, E, F ...] and the total items in this set [tot#]. The end user needs this information as part of the implementation of this particular laboratory machine.
    The particulars
    When the end user asks for an experiment to be run, we must specify some pieces of data to help them interpret the results. These are constructed as panels which contain discrete data elements.
    For example - One experiment may use two panels, Panel#1 and Panel #2. Panel #1 includes the items A, B, D, E, Panel #2 includes the items A, B, C, F, G.
    Thus, the panels may share some of the same items, but, I only want the unique members to be displayed in the text field. If I make a drop down box or checkboxes with the panels, I want to  be able to select the panels that we ran and (in this example) have the text field display only the unique items among all the panels that were used:
    textfield outpute = A, B, C, D, E, F, G - 7 total.
    Any assistance from the pdf community would be very much appreciated.
    Thanks!

    Thanks for that help.
    I should have made it more apparent that I'm very new to scripting and I'm
    not a programmer by trade. I have a few questions before modifying the code
    you kindly provided.
    1) Where should I embed this script? Within the 'selection change' area of
    my listbox?
    2) Can I replace the term 'arr' with the names of the various items in my
    listbox or should I put 'arr#' as the output value for each term?
    3) Will this script find and display the unique values when a user selects
    multiple items in my listbox?
    4) How does the script know where to output the unique members of the
    combined set?
    I appreciate your patience with me.
    ck

  • 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 allow input text field to accept more than one "specific" answer.

    Hi,
    I am working for something and trying to create a type-box-based quiz for one of my classes, where an input text field can change it's border color if 2 or more words from an accepted word list is inputed.
    For example, Say a list has possible answers: R,G, B, Y for the question "Name 2 colors".
    I want to create an input text box where the border of the box will change color if any 2 letters (in the above list) are entered into it.
    I've tried setting up a variable NumberSuccesses and setting it so that the number increases by 1 for each letter entered e.g.
    if (Ex.text == "R");
    NumSuc = NumSuc +1; // the var NumSuc has already been defined earlier in the code
    If (Ex.text ''G")
    NumSuc = NumSuc + 1
    if (NumSuc == 2)
    Ex.borderColor = 0x0000FF
    but that didn't work.. and I tried doing it with another function which I use for multiple input boxes like if there were boxes A, B, C. I could set up a general function where if the correct answers were entered into A, B, an C respectively, only then will say, a checkmark show up using a
    EnableCheckmark (); type function. Not sure how to do it if it's the same text input box though. Also just tried adding it into the same function re.
    If (Ex.text == "R" + "G")
    Ex.borderColor = 0x0000FF
    .. Does anyone know what else I can do?

    The solution of Nishu with Evaluation Logic:
    //These Are the Possible Answers
    var solutions:Array = new Array("A","B","C","D");
    function testInput(_inputText:String):Boolean
        //the delimiter could also be a comma, here it is a space
        var inputStringArray:Array = _inputText.split(" ");
        var counter:Number = 0;
        for (var i:int=0; i<inputStringArray.length; i++)
            for (var j:int=0; j<solutions.length; j++)
                if (inputStringArray[i]== solutions[j])
                    counter++;
        if (counter >=2)
            trace("true");
            return true;
        else
            trace("false");
            return false;
    //Textfield with name input_txt on stage
    input_txt.addEventListener(TextEvent.TEXT_INPUT, answerTxtInp);
    // The function that will be called by the event listener
    function answerTxtInp(txtEvent:TextEvent):void
         // depending on the possible answers of characters, change the border  color
         if(testInput(input_txt.text)){
             input_txt.borderColor = 0xFF0000;
         else{
             input_txt.borderColor = 0x000000;

  • How to auto complete text field

    Hello!
    I have the following behavior request for a text field.
    An user must write a date in a text field. The date format is yyyy/MM/dd (as 2003/02/04). The user would begin writing "2003" followed by the "0" character but would see in the text field "2003/0". The "/" would be automagically putted there.
    I hope this table will make the behavior more clear.
    User User
    writes sees this in the text field.
    2003 2003
    20030 2003/0
    200302 2003/02
    2003020 2003/02/0
    20030201 2003/02/01
    Also, if the user deletes the characters "1" and next the "0" from the previous example, it would automatically erase also the "/" character.
    Could someone point me to some sample code or give me some clues how to implement the previous behaviour? Does this pattern behavior has some well know name, where I can "google" for?
    Thanks!
    Eduardo

    Hello!
    I found a solution for my request feature, explained above.
    Maybe someone will find it also usefull.
    Regards,
    Eduardo
    public class JFormattedDateTextField extends JFormattedTextField {
    Format _formatDt = new SimpleDateFormat("yyyy/MM/dd");     
    public JFormattedDateTextField() {
         super();
         MaskFormatter mformat = null;
         try {
              mformat = new MaskFormatter("####/##/##");
         } catch (ParseException e1) {
              e1.printStackTrace();
         mformat.setPlaceholderCharacter('_');
         setFormatterFactory(new DefaultFormatterFactory(mformat));
         this.addFocusListener(new FocusAdapter() {
              public void focusGained(FocusEvent e) {
                   if (getFocusLostBehavior() == JFormattedTextField.PERSIST)
                        setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);
              public void focusLost(FocusEvent e) {
                   try {
                        Date dt = (Date) _formatDt.parseObject(getText());
                        setValue(_formatDt.format(dt));
                   } catch (ParseException pe) {
                        setFocusLostBehavior(JFormattedTextField.PERSIST);
                        setText("");
    public void setValue(Date strDt) {
         super.setValue(convertDateToStr(strDt));
    public Date getDateValue() {
         return convertStrToDate((String)super.getValue());
    public EFADateValue getEFADate() {
         return new EFADateValue(getDateValue());
    private Date convertStrToDate(String txt) {
         Date date = null;
         if (txt == null) return null;
         try {
              date = (Date)_formatDt.parseObject(txt);
         catch (ParseException pe) {
              date = null;
         return date;
    private String convertDateToStr(Date date) {
         try {
              return _formatDt.format(date);
         } catch (Exception e) {
              return "";

Maybe you are looking for

  • Change color for highlight words

    I'm using the highlight words column attribute for a report with a search parameter. I was wondering if there is a way to change the color of the text that is highlighted? The html that is generated wraps the highlighted word with <span style="font-w

  • Canon 7D Mark II error "Files are not recognized by the raw format support in Light (149)"?

    Has anyone tried to load raw files from a Canon 7D Mark II I get an error "Files are not recognized by the raw format support in Light (149)"?

  • Install ZEN Agent in different language as Windows language

    Is it possible and what has to be done to install the ZENworks Adaptive Agent 11 SP3 in English on a German Windows 7 Prof. SP1?

  • The ipad was corrupted

    When i was updating my ipad, at the end, itunes sends a message that says :the ipad firmware was corrupt, and the updating stops What can i do? I tried in another computer to update my ipad and nothing works I tried downloading the uptade in a webpag

  • CS5 InDesign crashes when I try to create a TOC

    I need to create a table of contents for my file. I have to choose "Table of Contents" from "Layout" three or four times before it actually activates, meaning, it shows me the loaded text icon. When it finally displays the icon, I place it at the top