Javascript validation of input field in HTMLB in jsp

Hi... i am using Javascript in HTMLB in JSP for input filed validations .
According to the requirement , the Input Field should start with only "Alphanumeric values" .
Can somebody please help me out in this.
Regards
Smita

Hi,
using java script can write like this
function validate(str){return str.substr(0,1) == str.substr(0,1).toUpperCase();}
Regards
Supraja
Edited by: Supraja Koganti on Nov 27, 2008 12:16 PM

Similar Messages

  • How to do validation of input fields

    Hi all,
              I have a rquirement to do the validation of input fields.Can anybody explain me how to go for that???Please explain in detail.U can also give me a link where i can find the tutorial for doing this.

    Hi Amit,
    What everyone has said above is correct - in the method of your action simply test for whatever condition you need to validate for.  However, the following tutorial shows you how to use Web Dynpro's Message Manager to display the messages on the screen in an easy user-friendly way:
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/wd%20java/wd%20tutorials/a%20simple%20input%20form%20with%20message%20and%20error%20service%20support.pdf">Enabling Message and Error Support</a>
    In addition, there are some validations that are done automatically depending on what you have your input fields set to - for instance, if you bind your input field to a date and a user enters words into the field instead of an actual date, it will automatically display an error message.  To learn how to turn this feature on and off, see this tutorial
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/edf6ea90-0201-0010-7696-a68662381c12">Using Validating and Non-Validating Actions</a>

  • Error in validation an input field in a table ui and high lighting the cell

    Hello All,
    I have a table ui in one of my application.   This table has, say 6 columns; out of these 6 columns 4 columns are shown as input fields.  User needs to put in some numbers in two of the fields.  I need to capture these two number fields data and subtract one from the other.  If number is negative , I need to let the user know by error message that the number is negative and they need to fix their input to make the answer positive.  I am able to do all this, but I am not able to high light the corresponding field which needs to be fixed.  Is there anyway I can do that...I mean high light the particular field as one gets it when we use the "report attribute error message" method of message manager class. 
    Secondly I can not halt the application, I need to do some work around for that using some flags.  Is there a simple way to halt the application, other than using flags and if condition?  I searched this forum, but could not find any definite answer....
    Thanks very much!
    Any help would greatly be appreicated.

    Hi....
    First you should have the table values in an internal  table.... for that yo need to get the values from the context like this....
    *DECLARE INTERNAL TABLE AND WORKAREA.
    data ls_nd_stru type wd_this->element_<node name>
    data lt_nd_table type wd_this->elements_<node name>
    get all declared attributes
    lo_nd_<your context node>->get_static_attributes_table(
                                               importing
                                               table = lt_nd_table ).
    *now your lt_nd_table will have the values.....what ever you have in the table.
    *then
    loop at lt_nd_table into ls_nd_stru.
    <.....your logic.....>
    <ie., read the current line of the field like
    ls_nd_stru-<field name1> = ls_nd_stru-<field name2> - ls_nd_stru-<field name3>
    then check error msg... based on your postive or negative values
    endloop.
    Hope this will help you....
    Thanks & regards
    Raja

  • Javascript to copy input fields to another input field..

    Hi,
    I have Permanent address fields(input text fields) (address line 1,2,city, state , country,zip code)  and present address fields with same input fields as premanent address
    and i have a check box is present address different with value Y when checked and N when unchecked
    so based on the check box checked and unchecked the permanent address should copy to present address.
    i dont know how to use java script in adf
    so some one  please help me to do this.
    thanks in advance
    cheers

    Hi Suchith,
    I will tell you how to achieve your case using the framework itself;
    1.- Add to your checkbox a setPropertyListener for each field you want to copy. So for the first one addressLine1 I assume the component value resides in your binding layer, you do
    from=#{bindings.yourCheckBox.inputValue eq 'Y' ? bindings.addressLine1.inputValue : null}
    to=#{bindings.otherAddressLine1.inputValue}
    type='valueChange'
    And the same for each field. All in the checkbox component.
    Since this is a business rule, you should always aim to write this kind of logic in the model layer so you can create a method in your ViewObjectRowImpl named copyAddress() and in there you copy the values from one field to another field. Then you expose this method in the client interface and execute it when clicking the checkbox. Add autosubmit=true and partialTrigger to the panel containing your other fields to be refreshed.
    Once again I am making a lot of assumptions about your model, but that is why you always need to first state the version of your JDeveloper, then give a clue about your model and where are the fields being stored and so on. So people can help you better.
    Regards

  • Validating monetary input fields

    Hi. We are developing a web site that supports English and French. Some of the web pages have forms where the user must enter monetary values. Since English and French monetary values use different formats, I am wondering if there's a Java API (that hasn't been deprecated or is obsolete) that would perform validation of these monetary values for us rather than us having to write these from scratch (granted, it would not be overly difficult)? I looked through the Internationalization tutorial but did not see anything on processing currency input, just on output formatting based on the locale (which works fine for us). Thanks...

    When I run the following program:
    import java.text.NumberFormat;
    import java.text.ParseException;
    import java.util.Locale;
    public class frmoney
        public static void main(String[] args)
         String number = (args.length < 1) ? "24,98" : args[0];
         NumberFormat nfc = NumberFormat.getCurrencyInstance(Locale.FRENCH);
         try {
             System.out.println("Parsing " + number);
             System.out.println(nfc.parse(number));
         catch (ParseException e)
             System.out.println(e);
    }I get:
    Parsing 24,98
    java.text.ParseException: Unparseable number: "24,98"

  • The javascript makes the input field to be null and cannot pass variable to

    Hi
    I use the following code to check whether the upload file is in the right format extension.
    However, once I use it and it cannot pass the variable to servlet and throw nullpointerexception.
    How can I fix it?
    <script language="JavaScript">
        extArray = new Array(".jpg", ".png", ".gif");
        function LimitAttach(form, file) {
        allowSubmit = false;
        if (!file) return;
        while (file.indexOf("\\") != -1)
        file = file.slice(file.indexOf("\\") + 1);
        ext = file.slice(file.indexOf(".")).toLowerCase();
        for (var i = 0; i < extArray.length; i++) {
        if (extArray[i] == ext) { allowSubmit = true; break; }
        if (allowSubmit) return true;
        else
        alert("Please only upload files that end in types:  "
        + (extArray.join("  ")) + "\nPlease select a new "
        + "file to upload and submit again.");
        return false;
    </script>
    OnSubmit="return LimitAttach(this.form, this.form.myimage.value)"
    servlet:
    boolean isMultipart = ServletFileUpload.isMultipartContent(request);

    the js works fine, just add id=myimage and it is ok
    checking file type for uploading only image on client side

  • Input field validation using JSP in HTMLB

    Hi All,
    How can we validate an input field in a form in BSP page.
    Like: There are two input fields in my form.I want the user to enter value in any one and only one of the fields.If the value is entered in both fields or none of the fields the user should get a popup and form  must not be submited.
    Shall i use the onClientClick attribute of Button element or doValidate attribute of Inputfield element or  validationScript attribute of From element?
    Please help.
    Thanks a lot,
    Anubhav.

    Here you go:
    <%@page language="abap" %>
    <%@extension name="htmlb" prefix="htmlb" %>
    <htmlb:content design="design2003" >
      <htmlb:page title=" " >
        <htmlb:form id="form1" >
          < script t-ype = "text/javascript" >     "Remove "-" between t & ype in type
          function checkInput()
           var field1 = document.form1.field1.value;
           var field2 = document.form1.field2.value;
    var error = "";
    if(field1 != "" && field2 != "")
              { error = "X";
                  javascript error message here          }
    if(field1 == "" && field2 ==  "")
              { error = "X";
                                javascript error message here
    if(error == "")
              htmlbSL(this,2,'mybutton:Submit');
          < / script >
              <htmlb:textView text      = "Hello World!"
                              textColor = "RED"
                              design    = "HEADER1"
                              align     = "CENTER" />
              <htmlb:inputField id        = "field1"
                                value     = "<%= var1 %>"
                                type      = "integer"
                                alignment = "CENTER" />
              <htmlb:inputField id        = "field2"
                                value     = "<%= var2 %>"
                                type      = "integer"
                                alignment = "CENTER" />
              <htmlb:button id            = "mybutton"
                            text          = "Press Me"
                            onClientClick = "javascript:checkInput();" />
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    Raja T
    Message was edited by:
            Raja Thangamani

  • Input field validation in a Table based on the value of other column

    Hi all
    I have a table with 2 columns. column1 is of text view and  column2 is Input field.
    The user should not be allowed to enter a value  in the column2 ( input field) greater than the value populated in column1(textview).
    So for Eg; if the column1 is populated with value 100, The user should not be able to enter a number greater than 100 in the column2  input field.
    Please let me how this can be achieved.
    I appreciate the help.
    Thanks

    Hi,
    Let me make sure u r working with table control.
    First u have to create a event(VALIDATE) to do the validation.
    Inside the event,
    1. First get the current index where user has pointed the curson
    2. Once u get the index read the internal table with index value.
    3. Now u can compare the col1 and col2 values and populate the error message.
    1. DATA : lo_elt TYPE REF TO if_wd_context_element,
                   l_index type i.
    lo_elt = wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ).
         CALL METHOD LO_ELT->GET_INDEX( RECEIVING  MY_INDEX = l_index.
    above code should be written inside the event.
    Thanks,

  • Validation of values in an input field.

    Hello togther,
    I've created an input field with a value-selector, so that the user can choose a value from help-list. But he can also enter a value directly into the input field. Is there any "STANDRAD" method to check whtether the value which is in the input field is valid against the values from the value-selector?
    I've found a standard method to check whether  mandatory fields are field and the method works fine. Is there anything like this also for checking values against values from the selector?
    Thanks in advance.
    Greetings,
    Florian

    Hello Florian,
                           You can create an event CHECK_DATA  for OnEnter event of  you input field.
    Then go to the Action tab and select the action type as Validation-Independent .
    Hope this will work for the input field with OVS help .
    Regards
    Vivek

  • Validating Input field in Web Dynpro

    Hi All,
    Could you please tell me how do I use set_attribute and get_attribute methods to get the user input from the dynpro screen?
    The user enters some data in the input field. I need to get this data and validate it.
    Please tell me how to get the user input.
    Thanks & Regards,
    Srilakshmi B

    hi,
    you can go through it,might be your problem solve.
    Example for Using Messages
    The following example shows how you can use messages created in the Message Editor. In the example, both messages with static text and messages that are dependent on user inputs – that is, messages with dynamic text – are defined.
    Description of Example
    Users can create a domain in this sample application. They can then enter a number in the next input field and press Click here to validate. If the specified number lies in the previously specified range, the user is informed of this fact in a standard message. If the number does not lie within this domain, the user sees a warning message.
    Prerequisites
    You have created a Web Dynpro application and defined view “MainView” within a Web Dynpro component.
    Procedure
    Creating the View
    Define the view as illustrated below:
    Context Creation:
    The context that provides the data is created as follows:
           1.      Create a context node, UIElem
           2.      Set the propertycardinality to 1..1 for the context node.
           3.      Create the context attributes a, b, and TypeField.
           4.      Set the Type of the context attributes to Integer.
    Data Binding
    To make the messages dynamic with regard to specification of the domain, the user inputs have to be saved. To do this, the input fields have to be bound to the context.
    sss
    Object
    Object ID
    Data Binding to Attribute
    Path Within the Context Structure
    a
    Input Field
    A
      MainView.UIElem.a
    b
    Input Field
    B
      MainView.UIElem.b
    Children_2
    Input Field
    TypeField
      MainView.UIElem.TypField
    In addition, bind the Children_3 pushbutton to action ValidateAction, which you also have to create.
    Creating Messages in the Message Pool
    The Web Dynpro tools provide a special message editor for defining messages of different types. 
    A message is defined by a specified key, message type, and message text. The message types  error,  warning, and  standard are predefined.
    Create the following messages:
    Messages Defined in the Message Editor
    Message Key
    Message Type
    Message text
    key1
    warning
    Please enter a number between the range of and !
      and are placeholders for the user input (the domain), which changes dynamically.
    key2
    standard
    The value entered is within the valid range.
    Implementation
    Because the messages are only displayed when the user Chooses Click here to validate, the messages must be implemented in the method onActionValidateAction:
    Implementierung der Methode onActionValidateAction()
    //@@begin imports
    import com.sap.tc.webdynpro.progmodel.controller.MessageManager;
    import com.sap.test.errorhandlingtest1.wdp.IMessageErrorhandlingTest1;
    import com.sap.test.errorhandlingtest1.wdp.IPrivateMainView;
    //@@end
    public void onActionValidateAction(
                           com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent)
        //@@begin
       int i = wdContext.currentUIElemElement().getTypField();
       int a = wdContext.currentUIElemElement().getA();
       int b = wdContext.currentUIElemElement().getB();
       MessageManager msgMgr =
             (MessageManager)wdThis.wdGetAPI().getComponent().getMessageManager();
       if (a < i && i < b)
             msgMgr.reportMessage(IMessageErrorhandlingTest1.KEY2, null, true);
       else
             Object[] arg ={new Integer(a), new Integer(b)};
             msgMgr.reportMessage(IMessageErrorhandlingTest1.KEY1, arg, true);
        //@@end
    The following tasks have been implemented in this method:
           1.      Read user inputs:
    int I = wdContext.currentUIElemElement().getTypField();
    int a = wdContext.currentUIElemElement().getA();
    int b = wdContext.currentUIElemElement().getB();
    1.       Read messages from the Message Manager:
    MessageManager msgMgr =
                 (MessageManager) wdThis.wdGetAPI().getComponent().getMessageManager();
    2.       Does the input lie within the defined domain?
    if (a < i && I < b)
    3.       Call the  standard message when the input lies within the domain:
    MsgMgr.reportMessage(IMessageErrorhandlingTest1.KEY2, null);
    Method reportMessage can be used to read the messages from the Message Manager. In this way you define the key and the objects that you want to change dynamically in the messages. Because no dynamic text was defined in your standard messages, you define null as a parameter.
    4.       Call the  warning messages when the input does not lie within the domain:
    Object[] arg ={new Integer(a), new Integer(b)};
    MsgMgr.reportMessage(IMessageErrorhandlingTest1.KEY1, arg);
    Because the warning messages ( Please enter a number between the range of  and !) contain text that depends on the user input, you also have to define the parameters for the domain in an object array. In the messages, the first object is then called from the array with (and the second with , and so on).
    Result
    After you have built and deployed your application, you can call it by choosing Run.
    If the user enters a number that lies within the defined domain, a standard message is displayed:
    If the user enters a number that does not lie within the defined domain, a warning message is displayed:

  • HTMLB .. Input field event handling..

    Hi guys,
    I have a input field htmlb in my jsp. I have to handle on blur event for this.. i.e if a user gives in somethin in the input field and once it looses focus, a event should get triggered. And probably in my case it will be helpful for me if I have this event handler method in the dynpage. For this kind of event handling what should I write in the followin tag
    <htmlb:inputfield id="" value="" width=""> plz tell me a tag attribute which supports this event.
    Regards,
    PP.

    Hi Priyanka,
                      You can get reference of your input field in JSP into DynPage. Do like this:
    Declare input field in JSP
    <hbj:inputfield id="input"  value="test">
    In DynPage, get refernce of the input field
    Wherever you want to trigger event
    InputField myInputField =(InputField) getComponentByName("input");
    myInputField.setClientEvent();
    Hope this helps.
    regards,
    Siva
    Note: If you get success, please post the solution before you close this thread.
    Message was edited by:
            Siva Rama Krushna

  • Validating Input fields in Interactive Adobe Forms with Webdynpro ABAP

    Dear Friends,
    Am new to Interactive Adobe forms with Webdynpro Abap,
    My scenario is, I have few Input fields, i need to handle the Messages when am not entering values in any of the Input Field,
    and raise the message when i click on Save Button.
    I have tried with setting the field as Required in Form itself, but i can't set the Field as Mandatory.
    I don't know how to do, Please give some needed points, as well needed some Script/Formcalc code.
    Thanks,
    Pradeep.

    Hi Pradeep,
    You can validate the fields by using javascript/formcalc logic in onclick event of button.
    Please refer the below links
    Adobe Form -How to make an Input Field Mandatory
    Validate Intercive Adobe Form
    Hope it helps you.
    Regards,
    Rama

  • Please Help. How to access to an input field in a table with javascript

    Hi
    i�m trying to access to the content of an input field that is in an table with a javascript function in this way
    function Valida_Tabla()
    var centro = document.getElementById("form1:idcentro").value;
    alert("Centro es ["+centro+"]")
    var des = document.getElementById("form1:table1:0:textField2").value;
    alert("des ["+des+"]")
    The fisrt alert is ok and displays the value of a field that is in a table.
    The second alert is not displayed.
    Is the syntax wrong?
    what i�m doing wrong
    Please help

    The best bet is to look at the source of the generated HTML and then use the exactly generated ID in the HTML source. When I looked at the HTML source I see the ID of a textfied inside a table as
    form1:table1:tableRowGroup1:0:tableColumn1:textField1
    - Winston
    http://blogs.sun.com/roller/page/winston?catname=Creator

  • Input Data Validation Of A Field Associated To A Check Table

    Hello,
    Does Web Dynpro have an inherent functionality to validate input fields associated to a check table?
    For example I created a structure with the field UNAME and defined USR02 as the check table for it.  And then I defined a UI InputField in my View and bind it to UNAME.  Web Dynpro does NOT seem to do an automatic validation to check if the value entered by the user exists in USR02. 
    Is there an interface or class that can be called in method WDDOBEFOREACTION to do the validation.  Or do we just have to do some manual validation using SELECT statements?
    Thanks.
    Giscard

    Hi Giscard,
    Web Dynpro does automatic validation when  you assign the check table  .
    You need not write any code as such.
    If the data which you entered is incorrect ,when you are trying to perform any action(like saving the data in data base or performing any further action with the wrong data that ia entered )
       the system throws an error message as"USERNAME -
    NOT IN THE SYSTEM'.
    Regards,
    Priya

  • How to check validation for a input field?

    For example, I need to check the validation of a field, if OK, then the field will be inputted, otherwise, there will rise a message, how can I implement that?
    Thanks and best regards,
    Anders

    Hi Andres,
    U can write a code in Request Processing--DO_VALIDATE_INPUT
    DATA: LR_BTADMINH       TYPE REF TO   CL_CRM_BOL_ENTITY.
      LR_BTADMINH  ?= ME->TYPED_CONTEXT->BTADMINH->COLLECTION_WRAPPER->GET_CURRENT( ).
        LV_ZZAFLD000057 = LR_ENTITY->GET_PROPERTY_AS_STRING( 'ZZAFLD000057' ).
    IF  LV_ZZAFLD000057 IS INITIAL.
    DATA: L7_MSG_SERVICE TYPE REF TO CL_BSP_WD_MESSAGE_SERVICE,
              LVSP_MSG_V1  TYPE STRING VALUE 'Spare in Progress'.
        L7_MSG_SERVICE = ME->VIEW_MANAGER->GET_MESSAGE_SERVICE( ).
        L7_MSG_SERVICE->ADD_MESSAGE(
            IV_MSG_TYPE       = 'E'
            IV_MSG_ID         = 'ZBSP'
            IV_MSG_NUMBER     = '008'
            IV_MSG_V1         = LVSP_MSG_V1 ).
    ENDIF.
    Regards,
    Lokesh.

Maybe you are looking for

  • Help- how do I make images ready for web gallery??

    Hi, I am trying to create a photo gallery of images within Bridge using the Adobe Web Gallery feature. I have the images I want to use in a folder.What steps do I need to take to get the images saved in the correct format and file size? Also, what fi

  • Ipad strange

    tried to send an imessage to my daughters ipad mini over the last couple of days . A new message every day / it starts to send then stops at about the 90 % mark . I gave up and used my iphone 4 . left the ipad on the dining table and made no changes

  • Grant the access rights to manager run the work flow history report without edit /delete rights

    I found that only Team Member / Workspace creator / Administrator can run the work flow history report. However, we have a Purchase Order request which need ask the supervisor for 1st approval and manager for 2nd approval. But those managers want to

  • My iPhone 4s keeps randomly prompting me for my iCloud password

    I keep just getting random prompts for my icloud password the last 1.5 weeks yet it is in settings, anyone else

  • Passing keystrokes into batch file

    I need to execute a batch file, with the following keystrokes to be passed during its execution: y enter y How do i simulate the above 3 keystrokes into the batch file? Thanks