HTMLB Form Validation using JavaScript

Hi All,
<b>
I have created a portal appliaction using JspDynPage.
I have created a form using HTMLB tags. I want to validate the inputfields before sending it to the server for processing.
The validation has to be done using Javascript
</b>
<b> How do i got about this ??? </b>
regards
Brahmachaitanya

I have written the following code to perform the validation.......
<b>
function validate()
          var funcName=htmlb_formid+"_getHtmlbElementId";
            func=window[funcName];
          var inpBox1 = eval(func('if1'));
          var eno=inpBox1.getValue();
          if(eno=='' || eno==null)
               alert('Please Enter Employee Number');
               htmlbevent.cancelSubmit=true;
          var inpBox2 = eval(func('if2'));
          var ename=inpBox2.getValue();
          alert(ename);
          if(ename=='' || ename==null)
               alert('Please Enter Employee Name');
               htmlbevent.cancelSubmit=true;
          var inpBox3 = eval(func('absencetype'));
          var atype=inpBox3.getValue();
          if(atype=='' || atype==null)
               alert('Please Enter Absence Type');
               htmlbevent.cancelSubmit=true;
          var inpBox4 = eval(func('if4'));
          var from=inpBox4.getValue();
          if(from=='' || from==null)
               alert('Please Enter From Date');
               htmlbevent.cancelSubmit=true;
          var inpBox5 = eval(func('if5'));
          var to=inpBox5.getValue();
          if(to=='' || to==null)
               alert('Please Enter To Date');
               htmlbevent.cancelSubmit=true;
          var inpBox6 = eval(func('if6'));
          var approve=inpBox6.getValue();
          if(approve=='' || approve==null)
               alert('Please Enter Approver Name');
               htmlbevent.cancelSubmit=true;
</b>
The problem now is that i am getting the <b> alert message only for Employee Number.</b>
<b> I am not getting the alerts if I leave the the other fields blank </b>
<b> How do i go about this ????????? </b>
regards
Brahmachaitanya

Similar Messages

  • Form Validation using Javascript error when adding extra fields

    Hi,
    I have a form (with a few fields which require validation) which works just fine.  I have added extra fields to the form and require them to validate too.  My problem is that they are not showing via the behaviours/validation box and I can't figure out how to sort it!  They are contained within the form element.  I have tried to delate the original validation and start again but to no avail.
    Please can someone help me?
    Code below.
    Many thanks
    function MM_validateForm() { //v4.0
      var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
      for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
        if (val) { nm=val.name; if ((val=val.value)!="") {
          if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
            if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
          } else if (test!='R') { num = parseFloat(val);
            if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
            if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
              min=test.substring(8,p); max=test.substring(p+1);
              if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
        } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
      } if (errors) alert('The following error(s) occurred:\n'+errors);
      document.MM_returnValue = (errors == '');
    //-->
    <form action="contact_us.asp" method="post" name="contact" target="_parent" class="contentText" id="contact">
          <table width="100%" border="0" cellspacing="5" cellpadding="0">
            <tr>
              <td width="54%" class="subHeader">Full Name* </td>
              <td width="46%" class="subHeader"><input name="FullName" type="text" id="FullName" /></td>
            </tr>
            <tr>
              <td class="subHeader">Company Name </td>
              <td class="subHeader"><input name="CompanyName" type="text" id="CompanyName" /></td>
            </tr>
            <tr>
              <td class="subHeader">Address</td>
              <td class="subHeader"><input name="Address1" type="text" id="Address1" /></td>
            </tr>
            <tr>
              <td class="subHeader"> </td>
              <td class="subHeader"><input name="Address2" type="text" id="Address2" /></td>
            </tr>
            <tr>
              <td class="subHeader"> </td>
              <td class="subHeader"><input name="Address3" type="text" id="Address3" /></td>
            </tr>
            <tr>
              <td class="subHeader">Postcode</td>
              <td class="subHeader"><input name="Postcode" type="text" id="Postcode" /></td>
            </tr>
            <tr>
              <td class="subHeader">Telephone Number* </td>
              <td class="subHeader"><input name="Telephone" type="text" id="Telephone" /></td>
            </tr>
            <tr>
              <td class="subHeader">Mobile Number </td>
              <td class="subHeader"><input name="Mobile" type="text" id="Mobile" /></td>
            </tr>
            <tr>
              <td height="25" class="subHeader">Email Address* </td>
              <td class="subHeader"><input name="Email" type="text" id="Email" /></td>
            </tr>
            <tr>
              <td height="30" class="subHeader">Status*</td>
              <td class="subHeader"><select name="StatusClass" id="StatusClass">
                <option selected="selected">Please Choose</option>
                <option>Architect</option>
                <option>Interior Designer</option>
                <option>Private Client</option>
                <option>Student</option>
                <option>Trade Enquiry</option>
              </select>          </td>
            </tr>
            <tr>
              <td height="23" class="subHeader">Project*</td>
              <td class="subHeader"><select name="Project" size="1" id="Project">
                <option selected="selected">Please Choose</option>
                <option>Planning Stages</option>
                <option>New Build</option>
                <option>Refurbishment</option>
                <option>Barn Conversion</option>
                <option>No project - information only</option>
              </select>          </td>
            </tr>
            <tr>
              <td height="37" class="subHeader">How did you hear about us?*</td>
              <td class="subHeader"><select name="CameFrom" size="1" id="CameFrom">
                <option selected="selected">Please Choose</option>
                <option>Web Search</option>
                <option>Grand Designs</option>
                <option>Living Etc</option>
                <option>Home Building &amp; Renovation</option>
                <option>Architect</option>
                <option>Friend/Family</option>
                <option>Magazine/Editorial</option>
                <option>Newspaper Article</option>
                <option>Trade Show/Exhibition</option>
                <option>Other</option>
              </select></td>
            </tr>
            <tr>
              <td height="24" class="subHeader">Brochure Request </td>
              <td class="subHeader"><input name="Brochure" type="checkbox" id="Brochure" value="checkbox" /></td>
            </tr>
            <tr>
              <td class="subHeader">Message</td>
              <td class="subHeader"><span class="style4">
                <textarea name="Message" id="Message"></textarea>
              </span></td>
            </tr>
            <tr>
              <td class="subHeader"> </td>
              <td class="subHeader"><input name="Submit" type="submit" value="Submit" /></td>
            </tr>
            <tr>
              <td colspan="2" class="subHeader"><em>* Required fields</em></td>
            </tr>
          </table>
          </form>

    whoops..... forgot to post this line of code which was a bit further down the page...
    "MM_validateForm('name','','R','number','','RisNum');return document.MM_returnValue">

  • Pre-validation using JavaScript cannot work in JSF?

    Sometimes we need to do pre-validation using JavaScript in some senarios that data need be entered and validated at client site before it reaches to Web Application Server. Remind that JSF is a server validation. Creator seems not to allow Developers to do pre-validation using JavaScript for any editable input fields in form. I will illustrate an example and hope anyone can help me to solve it out.
    Assume that if we write the a new web page that allows User enters Name and Phone. The pre-validation function called test() is written in JavaScript for validating field Phone. For simplicity, the below HTML/JavaScript without nested in table is a simple one for HTML form.
    <html>
    <body>
    <script language="JavaScript">
    function test(){
         if (form1.phone.value == "")
              alert("Please enter phone number in digits.");
              return false;
    </script>
    <form name=form1>
    <input id="phone" type="text" size=20><Br>
    <input id="name" type="text" size=20><Br>
    <input type="submit" id="submit" onclick="test()" value="Submit">
    </form>
    </body>
    </html>
    Now, we consider using Java Studio Creator to generate the same form as describing above. The script is shown below:
    <?xml version="1.0"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <html>
    <head>
    <title>testForm Title</title>
    </head>
    <body rave-layout="grid">
    <h:form binding="#{testForm.form1}" id="form1">
    <h:inputText binding="#{testForm.textField1}" id="phone" style="position: absolute; left: 192px; top: 96px; width: 168px; height: 23px"/>
    <h:inputText binding="#{testForm.textField2}" id="name" style="position: absolute; left: 192px; top: 144px; width: 168px; height: 23px"/>
    <h:commandButton binding="#{testForm.button1}" id="submit" style="position: absolute; left: 192px; top: 216px" value="Submit"/>
    </h:form>
    </body>
    </html>
    </f:view>
    </jsp:root>
    After running Script that Creator created, the HTML is generated and reduced (for simplicity) as follows:
    <f:view>
    <html>
    <body rave-layout="grid">
    <form action="/rave/rave" id="form1" method="post">
    <input id="form1:Phone" type="text"></input>
    <input id="form1:name" type="text"></input>
    <input id="form1:button1" value="Submit" onClick="test()"></input>
    </body>
    </html>
    </f:view>
    Take a look carefully at <input> elements. We see the syntax for naming for each "input" element that there is a semi colon added between form1 and phone or form1 and name. This syntax is generated from built-in JSF components. Hence, I rewrite the test() JavaScript function to match with the naming that Creator generated as follows:
    <script language="JavaScript">
    function test(){
         if (form1.form1:Phone.value == "")
              alert("Please enter phone number in digits.");
              return false;
    </script>
    Clearly, this JavaScript cannot be worked because of a semi column that Creator has named it.
    I have tried to work arround for this but cannot find a solution except changing the name such as: from <input id="form1:phone" ...> to <input id="form1_phone" ..>. But I could not change or modify the scripts because it is generated from JSF components when running it under browser.
    I guess to solve this problem, the naming for elements in form should be reconsidered in the next release of Java Studio Creator.

    Hi Marie,
    I currently sucess in client pre-validation using JSF. I found a way to do it.
    Please take a look of how javascript has been added in the following scripts:
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <html lang="en-US" xml:lang="en-US">
    <head>
    <meta content="no-cache" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    <title>login Title</title>
    </head>
    <body style="-rave-layout: grid">
    <h:form binding="#{login.form1}" id="form1">
    <h:outputLabel binding="#{login.componentLabel1}" for="componentLabel1" id="componentLabel1" style="position: absolute; left: 216px; top: 72px">
    <h:outputText binding="#{login.componentLabel1Text}" id="componentLabel1Text" value="Application System Name"/>
    </h:outputLabel>
    <h:panelGrid binding="#{login.gridPanel1}" columns="3" id="gridPanel1" style="position: absolute; left: 72px; top: 168px; width: 504px; height: 100px">
    <h:outputLabel binding="#{login.componentLabel2}" for="componentLabel2" id="componentLabel2">
    <h:outputText binding="#{login.componentLabel2Text}" id="componentLabel2Text" value="User Name: "/>
    </h:outputLabel>
    <h:inputText binding="#{login.textField1}" id="textField1" onclick="" style="width: 149px; height: 22px"/>
    <h:outputText binding="#{login.outputText1}" id="outputText1"/>
    <h:outputLabel binding="#{login.componentLabel3}" for="componentLabel3" id="componentLabel3">
    <h:outputText binding="#{login.componentLabel3Text}" id="componentLabel3Text" value="Password: "/>
    </h:outputLabel>
    <h:inputSecret binding="#{login.textField2}" id="textField2" style="width: 147px; height: 22px"/>
    <h:outputText binding="#{login.outputText2}" id="outputText2"/>
    <h:outputLabel binding="#{login.componentLabel4}" for="componentLabel4" id="componentLabel4">
    <h:outputText binding="#{login.componentLabel4Text}" id="componentLabel4Text"/>
    </h:outputLabel>
    <h:commandButton action="#{login.ok_action}" binding="#{login.button1}" id="button1" onclick="return checkUserIdentity(this.form)"
    style="width: 90px; height: 25px" value="OK"/>
    <h:outputLabel binding="#{login.componentLabel5}" for="componentLabel5" id="componentLabel5">
    <h:outputText binding="#{login.componentLabel5Text}" id="componentLabel5Text"/>
    </h:outputLabel>
    </h:panelGrid>
    </h:form>
    </body>
    <script type="text/javascript">
    function checkUserIdentity(form){
    var userName = form["form1:textField1"].value;
    var userPassword = form["form1:textField2"].value;
    if (userName == "") {
    alert("Please enter User Name.");
    form["form1:textField1"].focus();
    return false;
    if (userPassword == "" ){
    alert("Please enter password.");
    form["form1:textField2"].focus();
    return false;
    form.submit();
    return true;
    </script>
    </html>
    </f:view>
    </jsp:root>
    The key for getting data value from Form based on Javascripts is var userName = form["form1:textField1"].value;
    Thanks,
    VTT_

  • How to get values from a table(in jsp) for validation using javascript.

    hi,
    this is praveen,pls tell me the procedure to get values from a table(in jsp) for validation using javascript.
    thank you in advance.

    Yes i did try the same ..
    BEGIN
    select PROD_tYPE into :P185_OFF_CITY from
    magcrm_setup where atype = 'CITY' ;
    :p185_OFF_CITY := 'XXX';
    insert into mtest values ('inside foolter');
    END;
    When i checked the mtest table it shos me the row inserted...
    inside foolter .. Now this means everything did get execute properly
    But still the vallue of off_city is null or emtpy...
    i check the filed and still its empty..
    while mtest had those records..seems like some process is cleaining the values...but cant see such process...
    a bit confused..here..I tried on Load after footer...
    tried chaning the squence number of process ..but still it doesnt help
    some how the session variables gets changed...and it is changed to empty
    Edited by: pauljohny on Jan 3, 2012 2:01 AM
    Edited by: pauljohny on Jan 3, 2012 2:03 AM

  • How reset Acrobat form field using javascript API

    How reset Acrobat form field using javascript API

    There are several ways:
    resetForm(["Text1"]);
    or
    getField("Text1").value = getField("Text1").defaultValue;
    George

  • PLEASE help with server-side form validation using PHP!!!

    I feel like im going round and round in circles with this, after looking into all sorts of server-side advice i've come to the conclusion that i want to validate my form using server-side validation with PHP.
    So my form has several drop down menu's and  textareas  (not all of them need validation). For the part of my form i would like to validate, all i want is the drop downs to have to be changed/selected. So just a simple message like "You must select an option" if customers haven't done so. For the textareas, they just need to be filled out, so a message like "Information required" to come up if customers haven't done so.
    I believe i need to create a PHP page say for example 'error.php' place  the validation code in there and set this part of the the form to -
    <form name="product"form action="error.php" method="post" class="product_form">
    BUT im getting really confused with creating the code for the error.php. Please please can anyone help me with this!!!???
    Here are the drop down menu's i need validation on, error message being "You must select an option",
    "figurine"
    "engraving"
    "font"
    and here are the textareas that need validating, error message "Information required",
    "test"
    "Name"
    "house"
    "line_1"
    "line_2"
    "county"
    "postcode"
    "tel"
    www.milesmemorials.com/product-GK1.html
    I'd really appreciate any help!!!

    Ness_quick wrote:
    Great thats good enough for me. In that case, would you please be able to help me create the javascript for the above validation?? If you could just help me create it for this page i can amend it for all the other pages. I'd really really appreciate it!!!
    Can you follow the below example?? Obviously AFTER validation has been successful you need to collect the information from the form and send it to the recipient email address...that's where you can use php. I'll check back tomorrow and see how you are doing.
    <!DOCTYPE HTML>
    <html><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Form validation</title>
    <!-- VALIDATE ORDER FORM  -->
    <script type="text/javascript">
    <!--
    function RequiredFormFields() {
        // inform customer to provide figurine choice
    var figurine = document.forms.product.figurine.value;
    if (figurine == "-- Select figurine --")
    alert("Please provide figurine choice");
    return false;
    // inform customer to provide engraving choice
    var engraving = document.forms.product.engraving.value;
    if (engraving == "-- Select engraving --")
    alert("Please provide engraving choice");
    return false;
    // inform customer to provide font choice
        var font = document.forms.product.font.value;
    if (font == "-- Select style --")
    alert("Please select font style");
    return false;
    // inform customer to provide their name
    var Name = document.forms.product.Name.value;
    if (Name == null || Name == "")
    alert("Please provide your name");
    return false;
    // inform customer to provide their house number/name
    var house = document.forms.product.house.value;
    if (house == null || house == "")
    alert("Please provide your house number/name");
    return false;
    } // end function
    -->
    </script>
    </head>
    <body>
    <form name="product" form action="processForm.php" method="post" class="product_form" onsubmit="return RequiredFormFields()">
    <p class="product_form_options">Choice of Figurine<br>
    <select name="figurine" class="productButton" id="figurine" onChange="Recalculate()">
    <option selected>-- Select figurine --</option>
    <option value="7031">Tropical Green Granite with bronze sacred heart figurine as pictured(&pound;7031)</option>
    <option value="5216">Tropical Green Granite with bronze effect sacred heart figurine (&pound;5216)</option>
    <option value="5216">Tropical Green Granite with reconstituded figurine MF122(&pound;5216)</option>
    </select>
    </p>
    <p class="product_form_options">Engraved Lettering<br>
    <select name="engraving" class="productButton" id="engraving" onChange="Recalculate()">
            <option selected>-- Select engraving --</option>
            <option value="2.30">Sandblast and enamel painted (&pound;2.30/letter)</option>
            <option value="2.80">Sandblast and guilded (&pound;2.80/letter)</option>
            <option value="2.20">Maintenance free (&pound;2.20/letter)</option>
            <option value="3.73">Traditionally hand cut and enamel painted (&pound;3.73/letter)</option>
            <option value="3.98">Traditionally hand cut and gilded (&pound;3.98/letter)</option>
            <option value="4.34">Raised lead and enamel painted (&pound;4.34/letter)</option>
            <option value="4.59">Raised lead and gilded (&pound;4.59/letter)</option>
          </select>
    </p>
    <p class="product_form_options">Letter/Font Style<br>    
          <select name="font" class="productButton" id="font" >
               <option selected>-- Select style --</option>
               <option value="Maintenance free">Maintenance free </option>
               <option value="White painted block">White painted block</option>
               <option value="White painted roman">White painted roman</option>
               <option value="White painted Script">White painted Script</option>
               <option value="White painted Celtic">White painted Celtic</option>
               <option value="White painted Nova">White painted Nova</option>
               <option value="Sliver painted block">Sliver painted block</option>
               <option value="Sliver painted roman">Sliver painted roman</option>
               <option value="Sliver painted Script">Sliver painted Script</option>
               <option value="Sliver painted Celtic">Sliver painted Celtic</option>
               <option value="Sliver painted Nova">Sliver painted Nova</option>
               <option value="Gold leaf painted block">Gold leaf painted block</option>
               <option value="Gold leaf painted roman">Gold leaf painted roman</option>
               <option value="Gold leaf painted Script">Gold leaf painted Script</option>
               <option value="Gold leaf painted Celtic">Gold leaf painted Celtic</option>
               <option value="Gold leaf painted Nova">Gold leaf painted Nova</option>
               <option value="Gold leaf painted Old English">Gold leaf painted Old English</option>
             </select>
             </p>
             <p>
    <p>Name<br>
    <input name="Name" type="text" id="Name" value="">
    </p>
    <p>House name or number:<br>
    <input name="house" type="text" id="house" size="67">
    </p>
    <p>
    <input name="submit" type="submit" class="place_order" id="submit" value="Place order">
    </p>  
    </form>
    </body>
    </html>

  • Reading form data using javascript

    Hello.
    I want to go over the data received from the context to the PDF file using JavaScript, without binding it to any elements on the form.
    How can I access the data?
    I've tried using xfa.data or xfa.dataset, but didn't manage to get to it.
    How can it be done?
    Thanks.

    The following applies if it's a PDF generated from ABAP :
    Let's say a simple type parameter from context is named EBELN. To get it from javascript, you must use :
    $data.data.EBELN.value
    or
    $record.EBELN.value
    (it's the same)
    For example, to display the value, use:
    xfa.host.messageBox( $data.data.EBELN.value );
    Edited by: Sandra Rossi on Jan 28, 2009 7:34 PM : added $record line

  • How to give dropdownlist validation using javascript

    I have a sharepoint list, In that list i have a dropdown field,in that field i have values <--select-->,ram, raj like this, when user selected the <--select--> value and then click on savs button, it has to show the validation message like user
    need to select the value like that,using javascript or jquery i need to validate that.

    Hi ,
    add the following code in by  editing page.
    <script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    $("input[value='Save']").click(function(){
    var value = $("select[title='dropdown column name'] option:selected").text();
    if(value!="1"){
    alert(value);
    return false;
    https://social.technet.microsoft.com/Forums/security/en-US/4cd9429a-2261-4446-87d4-188ad10ae6c1/how-to-put-validation-in-sharepoint-list-item-for-dropdown-value-that-user-cannot-jump-from-first-to?forum=sharepointdevelopment
    http://sharepoint-2010-world.blogspot.in/2013/11/validate-dropdownlist-using-jquery.html
    Regards,
    Rajendra Singh
    If a post answers your question, please click Mark As Answer on that post and Vote as Helpful
    http://sharepointundefind.wordpress.com/

  • How to make the server slide form validation using JSP?

    anyone knows how to do server-side form validation??
    Thanks in advanced

    try this way
         //create a validation java class in that class u create separate methods for validating
         for example if u want to validate that a particular text box should not be empty
         then u can try this way
         say like this
         class ServerValidation()
         boolean message=false;
         public static boolean isTextBoxEmpty(String value)
         if(value.length<1)
         System.out.println("Text box is empty");
         message=false
         else
         message=true
         return message
    now say u r having a html page in which there is a text box on submiting u call say validate.jsp
    in this jsp u write this way
    <%
    String message=request.getParameter("name of ur text box");
    boolean b=ServerValidation.isTextBoxEmpty(message)
    if(b)
    //valid is true do ur other activity
    else
    String messageToUser="Please Enter Some value"
    u can now display this message on jsp and create a back button
    %>
    hope its clear

  • How do I clear a form text field during validation using JavaScript?

    I am just learning JavaScript and the Acrobat API.  I have a form created in adobe acrobat 9 standard (starting from an existing form in MS Excel).  There is a text field for a Social Security Number.  I have a custom format script and keystroke script and a custom validation script. I would like to add to the existing validation script, that if what is entered doesn't match the validation test, then clear out the field as in erase all the characters that were typed into the field.  I want this to happen no matter what.  So even if someone filled in a valid SSN number and then moved to the next field, but then went back to the SSN field and decided to change their entry and this new entry was "invalid" then clear out the field (do not revert to what was typed in the field originally, even though it was considered valid by the script).  (There is currently no default value for this field.)  Thank you inadvance for you help on this.
    Here is the current validation script:
    // only run when field not blank
    if (event.value != "")
    // RegExp for validation #########
    var re = /^(\d{3})(\d{2})(\d{4})$/
    if(re.test(event.value) == false)
    app.alert("Enter a 9-digit Social Security number with no spaces or special characters (e.g., 555555555). It will be converted to the format 555-55-5555.")
         //Here is where I've tried adding all of these lines, but none of them will clear out what is in the field
              //this.resetForm([event.target.name]);
              //event.target.value == "";
              //getField("SSN 1").value = getField("SSN 1").defaultValue;
              //getField("SSN 1").value == "";
              //event.rc = false;
    And incase these are somehow affecting it, here are the other scripts being processed on this field:
    Keystroke script:
    var input=event.value;
    var chars=input.length;
    if( event.willCommit || chars==8 )this.getField("Name 1").setFocus();
    Format script:
    var re = /^(\d{3})(\d{2})(\d{4})$/
    if(re.test(event.value) == true)
    // add "-"
    event.value = RegExp.$1 + "-" + RegExp.$2 + "-" + RegExp.$3;

    Thank you very much.  I did try that before, but I was using event.value == "";  I guess in this case I'm assigning the value of "", not making the value equal "".

  • HTMLb form validation

    I am using EP6 SP2 Patch27
    Has anyone been able to create a button, set it to be an OKButton and actually get the ClientEvent handling functionality to work. Basically I am trying to get the input fields to be validated as being mandatory, but nothing I seem to be doing works. I have tried using
    <hbj:inputField
    id="companyname_if"
    design="STANDARD"
    width="300"
    jsObjectNeeded="true">
    <%
    companyname_if.setRequiresValidation(true);
    companyname_if.setClientEvent(EventTrigger.ON_VALIDATION, "alert('Hello');");
    if ( componentRequest.getUser().getAttribute(IUser.DEFAULT_NAMESPACE, "company") != null )
         companyname_if.setValue(componentRequest.getUser().getAttribute(IUser.DEFAULT_NAMESPACE, "company")[0]);
    %>
    </hbj:inputField>
    But this doesn't seem to trigger a client side event. I have also tried the ON_FORM_SUBMIT, which didn't work either. This code has been set on an InputField htmlb object (or tag as I am using a JSP). The strange thing is that the script works when using the ON_FOCUS or ON_BLUR, therefore I assume that I am missing something either on the form or the button, but I am unsure.
    Any thooughts
    Thanks
    Darrell
    Message was edited by: Darrell Merryweather

    I had already spotted this forum posting and it doesn't help unfortunately. As I mentioned, I can get some of the Events to work, however, from what I can tell from the limited documentation on this there is supposed to be an event triggered when the form is submitted, and/or an event triggered signalling that there is some validation to be performed.
    I could easily simulate the stuff that you mention in your code by having the button set to the default button for the form and having an onClientClick event for the button calling some Javascript. My problem then is that I don't have access to all of the InputFields on that form if I do it like this.
    Thanks anyway
    D

  • TableView row cell content validation using Javascript

    Hi ,
       I need to validate the tableView cell which is opened for input as like text box using Iterator. I have a requirement to validate the cell when the row is selected.
       I tried with document.getElementById("solgrp_1_1").value, where solgrp is tableView id.
      Some how it is not working for me? and the second how can i recognise the row is selected or not in java script.
      Any input will help me. please sesuggest with your ideas.
    Regards,
    Praveen

    Hi Jan,
    If I undestood your question properly, you cannot know for sure that the row will be - in the end - selected because of the singleselect/multiselect issue.
    So, either you put the logic on the server side and give up the JS solution... or you have to inject some variables mirroring the selectionMode into Javascript so that you can test it in your JS validation function.
    Regarding the value of a cell, you can peform a document.getElementById( <id> ).value where <id> is of the form :
    <id_of_the_tableview>_<row_index>_<col_index>
    Check this in the source code of your page.
    Best regards,
    Guillaume
    Best regards,
    Guillaume

  • Manually submit a form without using javascript?

    i'm trying to automate registration of a site by using java (no gui). However there is no direct submit button or form.submit() present in its registration url. Checked the javascript codes and it opens a window, and checks if the window opener is present .
    if (window.opener && !window.opener.closed)
    window.opener.document.theForm.submit();
    window.close();               
    }Is there a solution for this problem?

    I'm trying to access an http url (not mine).
    (1) By setting post variables , I can retrieve the html of the url as string. Here's the code.
         static String getHtml(String url_nm, HashMap variables)
              String html = "";
              String data = "";
              boolean firstRun = true;
              if (variables != null)
                   Set keys = variables.keySet();
                   Iterator iterator = keys.iterator();
                   while (iterator.hasNext())
                        if (firstRun)
                             firstRun = false;
                        else
                             data += "&";
                        String name = iterator.next().toString();
                        try
                             data += URLEncoder.encode(name, "UTF-8") + "=" +
                                  URLEncoder.encode(variables.get(name).toString(), "UTF-8");
                        catch (Exception e1)
              try {
                 URL url = new URL(url_nm);
                 URLConnection conn = url.openConnection();
                 conn.setDoOutput(true);
                 OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
                 wr.write(data);
                 wr.flush();
                 BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                 String line;
                 while ((line = rd.readLine()) != null) {
                      html += line;
                 wr.close();
                 rd.close();
             } catch (Exception e) {
                  e.printStackTrace();
              return html;
    [/code
    (2) The problem is even if i set the post variables, i cannot submit the form since the form can only be submitted if i was actually browsing it in a web browser. The html displays a window where the actual submit  form is set (as you can see in my later post) .                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Check box validation using Javascript

    Hi Everyone,
    I am using LiveCycle with my form that have multiple sections in the form that have questions that have a check box yes or  check box no next to it.  The user can either choose yes or no. Note: I am not using radio buttons.   I am looking for a Javascript function or code that when clicking a button I have set up as "regular" can check to see if a user selected either check boxes (yes) or check box (no) and validate that in that section the user has answered all question by selecting either yes or no.  Example; Section (1) has (5) questions with a yes or no check box next to each question.  I want to validate that the user selected 5 check boxes for this section (regardless if yes or no was answered for each)  if only 2 out od the 5 questions were answered with either yes or no.  I generate an error message. 
    I already have a function that searches the form and tells me how many manditory text fields have been left blank and throws an error.  I would like the check box function to be the same.  Any help would be appreciated.
    Thanks
    Jagan

    function validateCheckBox()
    if(document.TestJsp.BONUS.checked)
    return true;
    var len = document.TestJsp.BONUS.length;
    for(i = 0 ; i < len; i++)
    if(document.TestJsp.BONUS.checked)
    return true;
    return false;
    Sorry for the triple post. :=)

  • Simultaneous Client and Server Form Validation using Custom Tag Library

    I am developing a custom tag library for validator tags
    which are capable of doing client side validation (Javascript)
    and server side (Java). My problem is with the development
    of a regular expression based validator. Because of differences
    in the way Javascript and Java handle regular expressions
    i can not use the same regular expression for both types of
    validation. Is there any way to convert a valid regular
    expression from the java.util.regex format into the Javascript
    format or vice versa? My major problems are with the (or, ||)
    statements and the user of backslashes.

    If you are speaking of RE syntax flavours, they are basically the same(namely perl5 flavour). Any expression that works in JS should work in j.u.regex too.
    Though, their usage is quite different.
    So, there is no need for convertion of expressions.
    But porting the code may be not so trivial.

Maybe you are looking for

  • I created a banner for my site. On that banner I want to create a text animation preferibly in flash

    cs4. I need the text to appear throught the left side an on to the middle of the banner and dissapear. I also need animated text to come in through the right side and do the same. Can anybody give me somne ideas or links to videos where I can ssee ho

  • Problem while reading special characters in java

    Hi i am faving the follwing xml. <ns1:dc_application_bullets> <w:p wsp:rsidR="004E4084" wsp:rsidRPr="007024E6" wsp:rsidRDefault="000D5B97" wsp:rsidP="007024E6"> <w:r> <w:rPr> <w:rFonts w:ascii="Arial Unicode MS" w:fareast="Arial Unicode MS" w:h-ansi=

  • Macbook pro dont run reinstallation disc.

    My problem begin when my macbook pro start showing a blinkin folder at start up, i had this problem before on an ibook. I inserted my reinstallation CD. but i have a new problem. The first screen apears to be scratchy, It look like a old tv with bad

  • Location services indication won't shut off after reboot

    Hello, My app uses location services in the background. I'm turning the location services on for short time intervals, trying to keep the battery power. I'm not using any significant location monitoring nor region monitoring. Everything works as expe

  • Excel time string

    Hello, i've got a problem with an Excel import. One cell is a date like 07.2.2008. LV reads it a string array with 39485 for the date. Is it possible to transform it back to the date? Markus