JavaScript onSubmit

Does one anyone know if it is possible to trigger a JavaScript onSubmit when a list entry is clicked in a List type region? I would like to validate the value in a item when a list entry is clicked but validations are only performed when the page is submitted.

Scott,
Try Raj's suggestion: Submit a page from a list
Scott

Similar Messages

  • Validate long date in javascript & OnSubmit problem

    hi i need to validate long date format "E, dd MMM yyyy HH:mm:ss" or Thu, 18 Jul 2002 12:52:49 that is key in by the user. but i'm not sure how to do this. i have couples of input data and i'm passing an object to the javascript function validateform using OnSubmit. Which one is better, using OnSubmit or OnCick for this kind of parameter passing. Eg <form method="POST" action="insert.jsp" onSubmit="return validateForm(this)"> However i'm having a problem where when there is an invalid input from the user, it will notify the user but it will also send the form to the insert.jsp at the same time. Therefore the user can't correct the invalid data. The function return false for valid input and true for invalid. Please help!!! urgent.... thanks in advance

    Your problem is you have used
    <input type="submit" onClick="OnSubmit();">
    this won't work.
    Instead try
    <input type="button" value="someValue" onClick="OnSubmit();">
    This may help. All the best.

  • Why this code is not working??? java script

    gen_validatorv2.js
         JavaScript Form Validator
    Version 2.0.2
         Copyright 2003 JavaScript-coder.com. All rights reserved.
         You use this script in your Web pages, provided these opening credit
    lines are kept intact.
         The Form validation script is distributed free from JavaScript-Coder.com
         You may please add a link to JavaScript-Coder.com,
         making it easy for others to find this script.
         Checkout the Give a link and Get a link page:
         http://www.javascript-coder.com/links/how-to-link.php
    You may not reprint or redistribute this code without permission from
    JavaScript-Coder.com.
         JavaScript Coder
         It precisely codes what you imagine!
         Grab your copy here:
              http://www.javascript-coder.com/
    function Validator(frmname)
    this.formobj=document.forms[frmname];
         if(!this.formobj)
         alert("BUG: couldnot get Form object "+frmname);
              return;
         if(this.formobj.onsubmit)
         this.formobj.old_onsubmit = this.formobj.onsubmit;
         this.formobj.onsubmit=null;
         else
         this.formobj.old_onsubmit = null;
         this.formobj.onsubmit=form_submit_handler;
         this.addValidation = add_validation;
         this.setAddnlValidationFunction=set_addnl_vfunction;
         this.clearAllValidations = clear_all_validations;
    function set_addnl_vfunction(functionname)
    this.formobj.addnlvalidation = functionname;
    function clear_all_validations()
         for(var itr=0;itr < this.formobj.elements.length;itr++)
              this.formobj.elements[itr].validationset = null;
    function form_submit_handler()
         for(var itr=0;itr < this.elements.length;itr++)
              if(this.elements[itr].validationset &&
         !this.elements[itr].validationset.validate())
              return false;
         if(this.addnlvalidation)
         str =" var ret = "+this.addnlvalidation+"()";
         eval(str);
    if(!ret) return ret;
         return true;
    function add_validation(itemname,descriptor,errstr)
    if(!this.formobj)
         alert("BUG: the form object is not set properly");
              return;
         }//if
         var itemobj = this.formobj[itemname];
    if(!itemobj)
         alert("BUG: Couldnot get the input object named: "+itemname);
              return;
         if(!itemobj.validationset)
         itemobj.validationset = new ValidationSet(itemobj);
    itemobj.validationset.add(descriptor,errstr);
    function ValidationDesc(inputitem,desc,error)
    this.desc=desc;
         this.error=error;
         this.itemobj = inputitem;
         this.validate=vdesc_validate;
    function vdesc_validate()
    if(!V2validateData(this.desc,this.itemobj,this.error))
    this.itemobj.focus();
              return false;
    return true;
    function ValidationSet(inputitem)
    this.vSet=new Array();
         this.add= add_validationdesc;
         this.validate= vset_validate;
         this.itemobj = inputitem;
    function add_validationdesc(desc,error)
    this.vSet[this.vSet.length]=
         new ValidationDesc(this.itemobj,desc,error);
    function vset_validate()
    for(var itr=0;itr<this.vSet.length;itr++)
         if(!this.vSet[itr].validate())
              return false;
         return true;
    function validateEmailv2(email)
    // a very simple email validation checking.
    // you can add more complex email checking if it helps
    if(email.length <= 0)
         return true;
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    var regexp_user=/^\"?[\w-_\.]*\"?$/;
    if(splitted[1].match(regexp_user) == null) return false;
    if(splitted[2] != null)
    var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
    if(splitted[2].match(regexp_domain) == null)
         var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
         if(splitted[2].match(regexp_ip) == null) return false;
    }// if
    return true;
    return false;
    function V2validateData(strValidateStr,objValue,strError)
    var epos = strValidateStr.search("=");
    var command = "";
    var cmdvalue = "";
    if(epos >= 0)
    command = strValidateStr.substring(0,epos);
    cmdvalue = strValidateStr.substr(epos+1);
    else
    command = strValidateStr;
    switch(command)
    case "req":
    case "required":
    if(eval(objValue.value.length) == 0)
    if(!strError || strError.length ==0)
    strError = objValue.name + " : Required Field";
    }//if
    alert(strError);
    return false;
    }//if
    break;
    }//case required
    case "maxlength":
    case "maxlen":
    if(eval(objValue.value.length) > eval(cmdvalue))
    if(!strError || strError.length ==0)
    strError = objValue.name + " : "+cmdvalue+" characters maximum ";
    }//if
    alert(strError + "\n[Current length = " + objValue.value.length + " ]");
    return false;
    }//if
    break;
    }//case maxlen
    case "minlength":
    case "minlen":
    if(eval(objValue.value.length) < eval(cmdvalue))
    if(!strError || strError.length ==0)
    strError = objValue.name + " : " + cmdvalue + " characters minimum ";
    }//if
    alert(strError + "\n[Current length = " + objValue.value.length + " ]");
    return false;
    }//if
    break;
    }//case minlen
    case "alnum":
    case "alphanumeric":
    var charpos = objValue.value.search("[^A-Za-z0-9]");
    if(objValue.value.length > 0 && charpos >= 0)
    if(!strError || strError.length ==0)
    strError = objValue.name+": Only alpha-numeric characters allowed ";
    }//if
    alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
    return false;
    }//if
    break;
    }//case alphanumeric
    case "num":
    case "numeric":
    var charpos = objValue.value.search("[^0-9]");
    if(objValue.value.length > 0 && charpos >= 0)
    if(!strError || strError.length ==0)
    strError = objValue.name+": Only digits allowed ";
    }//if
    alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
    return false;
    }//if
    break;
    }//numeric
    case "alphabetic":
    case "alpha":
    var charpos = objValue.value.search("[^A-Za-z]");
    if(objValue.value.length > 0 && charpos >= 0)
    if(!strError || strError.length ==0)
    strError = objValue.name+": Only alphabetic characters allowed ";
    }//if
    alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
    return false;
    }//if
    break;
    }//alpha
              case "alnumhyphen":
    var charpos = objValue.value.search("[^A-Za-z0-9\-_]");
    if(objValue.value.length > 0 && charpos >= 0)
    if(!strError || strError.length ==0)
    strError = objValue.name+": characters allowed are A-Z,a-z,0-9,- and _";
    }//if
    alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
    return false;
    }//if                
                   break;
    case "email":
    if(!validateEmailv2(objValue.value))
    if(!strError || strError.length ==0)
    strError = objValue.name+": Enter a valid Email address ";
    }//if
    alert(strError);
    return false;
    }//if
    break;
    }//case email
    case "lt":
    case "lessthan":
    if(isNaN(objValue.value))
    alert(objValue.name+": Should be a number ");
    return false;
    }//if
    if(eval(objValue.value) >= eval(cmdvalue))
    if(!strError || strError.length ==0)
    strError = objValue.name + " : value should be less than "+ cmdvalue;
    }//if
    alert(strError);
    return false;
    }//if
    break;
    }//case lessthan
    case "gt":
    case "greaterthan":
    if(isNaN(objValue.value))
    alert(objValue.name+": Should be a number ");
    return false;
    }//if
    if(eval(objValue.value) <= eval(cmdvalue))
    if(!strError || strError.length ==0)
    strError = objValue.name + " : value should be greater than "+ cmdvalue;
    }//if
    alert(strError);
    return false;
    }//if
    break;
    }//case greaterthan
    case "regexp":
                   if(objValue.value.length > 0)
         if(!objValue.value.match(cmdvalue))
         if(!strError || strError.length ==0)
         strError = objValue.name+": Invalid characters found ";
         }//if
         alert(strError);
         return false;
         }//if
    break;
    }//case regexp
    case "dontselect":
    if(objValue.selectedIndex == null)
    alert("BUG: dontselect command for non-select Item");
    return false;
    if(objValue.selectedIndex == eval(cmdvalue))
    if(!strError || strError.length ==0)
    strError = objValue.name+": Please Select one option ";
    }//if
    alert(strError);
    return false;
    break;
    }//case dontselect
    }//switch
    return true;
         Copyright 2003 JavaScript-coder.com. All rights reserved.
    example.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Example for Validator</title>
    <script language="JavaScript" src="gen_validatorv2.js" type="text/javascript"></script>
    </head>
    <body>
    <form action="" name="myform" >
    <table cellspacing="2" cellpadding="2" border="0">
    <tr>
    <td align="right">First Name</td>
    <td><input type="text" name="FirstName"></td>
    </tr>
    <tr>
    <td align="right">Last Name</td>
    <td><input type="text" name="LastName"></td>
    </tr>
    <tr>
    <td align="right">EMail</td>
    <td><input type="text" name="Email"></td>
    </tr>
    <tr>
    <td align="right">Phone</td>
    <td><input type="text" name="Phone"></td>
    </tr>
    <tr>
    <td align="right">Address</td>
    <td><textarea cols="20" rows="5" name="Address"></textarea></td>
    </tr>
    <tr>
    <td align="right">Country</td>
    <td>
         <SELECT name="Country">
              <option value="" selected>[choose yours]
              <option value="008">Albania
              <option value="012">Algeria
              <option value="016">American Samoa
              <option value="020">Andorra
              <option value="024">Angola
              <option value="660">Anguilla
              <option value="010">Antarctica
              <option value="028">Antigua And Barbuda
              <option value="032">Argentina
              <option value="051">Armenia
              <option value="533">Aruba     
         </SELECT>
         </td>
    </tr>
    <tr>
    <td align="right"></td>
    <td><input type="submit" value="Submit"></td>
    </tr>
    </table>
    </form>
    <script language="JavaScript" type="text/javascript">
    //You should create the validator only after the definition of the HTML form
    var frmvalidator = new Validator("myform");
    frmvalidator.addValidation("FirstName","req","Please enter your First Name");
    frmvalidator.addValidation("FirstName","maxlen=20",
         "Max length for FirstName is 20");
    frmvalidator.addValidation("FirstName","alpha");
    frmvalidator.addValidation("LastName","req");
    frmvalidator.addValidation("LastName","maxlen=20");
    frmvalidator.addValidation("Email","maxlen=50");
    frmvalidator.addValidation("Email","req");
    frmvalidator.addValidation("Email","email");
    frmvalidator.addValidation("Phone","maxlen=50");
    frmvalidator.addValidation("Phone","numeric");
    frmvalidator.addValidation("Address","maxlen=50");
    frmvalidator.addValidation("Country","dontselect=0");
    </script>
    </body>
    </html>
    documentation.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
         <title>JavaScript Form Validator Documentation</title>
    <Style>
    BODY, P,TD{ font-family: Arial,Verdana,Helvetica, sans-serif; font-size: 10pt }
    H1{ font-family: Arial,Verdana,Helvetica, sans-serif; font-size: 18pt; color : #000066}
    H3{ font-family: Arial,Verdana,Helvetica, sans-serif; font-size: 12pt; color : #000066 }
    A{font-family: Arial,Verdana,Helvetica, sans-serif;}
    B {     font-family : Arial, Helvetica, sans-serif;     font-size : 12px;     font-weight : bold;}
    CODE {font-family : Courier,monospace;font-size: 10pt;color : #800000;}
    CODE.htm {font-family : "Courier New", Courier, monospace;     font-size : x-small;     color : #000080;}
    </Style>
    </head>
    <body>
    <center>
    <table cellspacing="2" cellpadding="2" border="0" width="600">
    <tr><td>
         <h1>JavaScript Form Validations Made Easy!</h1>
         <h3>Documentation for JavaScript Form Validator</h3>
         <HR size=1>
         <P>
         The Form validation script is distributed free from JavaScript-Coder.com<br>
         You can use the script in your web pages for free.
         </P>
         <P>
         You may please add a link to JavaScript-Coder.com,
         making it easy for others to find this script.<br>
         Checkout the <A href="http://www.javascript-coder.com/links/how-to-link.php
         target="_blank">Give a Link & Get a Link!</A> page.
         </P>
         <P>
         <B>JavaScript Coder</B><br>
         It precisely codes what you imagine!<br>
         Grab your copy here: http://www.javascript-coder.com
         </P>
         <HR size=1>
         <P>
         Using client side JavaScript is an efficient way to validate the user input
         in web applications. When there are many fields in the form, the JavaScript
         validation becomes too complex.
         </P>
         <P>
    The JavaScript class presented here makes the form validations many times easier.
         </P>
         <P>
         The idea is to create a set of "validation descriptors" associated with each element
         in a form. The "validation descriptor" is nothing but a string specifying the type of
         validation to be performed.
         </P>
         <P>
         Each field in the form can have 0, 1, or more validations. For example, the input should
         not be empty, should be less than 25 chars, should be alpha-numeric, etc
         </P>
         You can associate a set of validation descriptors for each input field in the form.
         <a name="3"></a>
         <h3>Using The Script</h3>
         1.Include gen_validatorv2.js in your html file just before closing the HEAD tag<br><br>
         <CODE>
         <script language="JavaScript" src="gen_validatorv2.js" type="text/javascript"></script><BR>
         </head><BR>
         </CODE><br>
         2. Just after defining your form,
         Create a form validator object passing the name of the form<br><br>
         <CODE class='htm'>
          <FORM name='myform' action=""><BR>
          <!----Your input fields go here --><BR>
          </FORM><BR>
         </CODE><CODE>
          <SCRIPT language="JavaScript"><BR>
          var frmvalidator  = new Validator("myform");<BR>
         </CODE>
         <br>
         <br>
         3. Now add the validations required<br><br>
         <CODE>
              frmvalidator.addValidation("FirstName","alpha");
         </CODE><br><br>
         the first argument is the name of the field and the second argument is the
         validation descriptor, which specifies the type of validation to be performed.<br>
         You can add any number of validations.The list of validation descriptors are provided
         at the end of the documentation.<br>
         The optional third argument is the error string to be displayed if the validation
         fails.<br>
         <br>
         <CODE>
              frmvalidator.addValidation("FirstName","alpha");<br>
              frmvalidator.addValidation("FirstName","req","Please enter your First Name");<br>
              frmvalidator.addValidation("FirstName","maxlen=20",<br>
                   "Max length for FirstName is 20");          <br>
         </CODE>     <br>
         <br>
         4. Similarly, add validations for the fields where validation is required.<br>
         That's it! You are ready to go.
         <A name="3"></A>
         <h3>Example</h3>
         The example below will make the idea clearer<br>
         <CODE class="htm">
                   <form action="" name="myform" ><BR>
                   <table cellspacing="2" cellpadding="2" border="0"><BR>
                   <tr><BR>
                     <td align="right">First Name</td><BR>
                     <td><input type="text" name="FirstName"></td><BR>
                   </tr><BR>
                   <tr><BR>
                     <td align="right">Last Name</td><BR>
                     <td><input type="text" name="LastName"></td><BR>
                   </tr><BR>
                   <tr><BR>
                     <td align="right">EMail</td><BR>
                     <td><input type="text" name="Email"></td><BR>
                   </tr><BR>
                   <tr><BR>
                     <td align="right">Phone</td><BR>
                     <td><input type="text" name="Phone"></td><BR>
                   </tr><BR>
                   <tr><BR>
                     <td align="right">Address</td><BR>
                     <td><textarea cols="20" rows="5" name="Address"></textarea></td><BR>
                   </tr><BR>
                   <tr><BR>
                     <td align="right">Country</td><BR>
                     <td><BR>
                          <SELECT name="Country"><BR>
                             <option value="" selected>[choose yours]<BR>
                             <option value="008">Albania<BR>
                             <option value="012">Algeria<BR>
                             <option value="016">American Samoa<BR>
                             <option value="020">Andorra<BR>
                             <option value="024">Angola<BR>
                             <option value="660">Anguilla<BR>
                             <option value="010">Antarctica<BR>
                             <option value="028">Antigua And Barbuda<BR>
                             <option value="032">Argentina<BR>
                             <option value="051">Armenia<BR>
                             <option value="533">Aruba     <BR>
                         </SELECT><BR>
                        </td><BR>
                   </tr><BR>
                   <tr><BR>
                     <td align="right"></td><BR>
                     <td><input type="submit" value="Submit"></td><BR>
                   </tr><BR>
                   </table><BR>
                   </form><BR>
                   </CODE><CODE>
                   <script language="JavaScript" type="text/javascript"><BR>
                    var frmvalidator = new Validator("myform");<BR>
                    frmvalidator.addValidation("FirstName","req","Please enter your First Name");<BR>
                    frmvalidator.addValidation("FirstName","maxlen=20",<BR>
                        "Max length for FirstName is 20");<BR>
                    frmvalidator.addValidation("FirstName","alpha");<BR>
                    <BR>
                    frmvalidator.addValidation("LastName","req");<BR>
                    frmvalidator.addValidation("LastName","maxlen=20");<BR>
                    <BR>
                    frmvalidator.addValidation("Email","maxlen=50");<BR>
                    frmvalidator.addValidation("Email","req");<BR>
                    frmvalidator.addValidation("Email","email");<BR>
                    <BR>
                    frmvalidator.addValidation("Phone","maxlen=50");<BR>
                    frmvalidator.addValidation("Phone","numeric");<BR>
                    <BR>
                    frmvalidator.addValidation("Address","maxlen=50");<BR>
                    frmvalidator.addValidation("Country","dontselect=0");<BR>
                   </script><BR>     
         </CODE>
         <A name="4"></A>
         <h3>Some Additional Notes</h3>
         <LI type="disc">The form validators should be created only after defining the HTML form
         (only after the </form> tag. )<br>
         <LI type="disc">Your form should have a distinguished name.
         If there are more than one form
         in the same page, you can add validators for each of them. The names of the
         forms and the validators should not clash.
         <LI type="disc">You can't use the javascript onsubmit event of the form if it you are
         using this validator script. It is because the validator script automatically overrides the
         onsubmit event. If you want to add a custom validation, see the section below
         </LI>
         <A name="5"></A>
         <h3>Adding Custom Validation</h3>
         If you want to add a custom validation, which is not provided by the validation descriptors,
         you can do so. Here are the steps:
         <LI type="disc">Create a javascript function which returns true or false depending on the validation.<br>
         <CODE>
              function DoCustomValidation()<BR>
              {<BR>
                var frm = document.forms["myform"];<BR>
                if(frm.pwd1.value != frm.pwd2.value)<BR>
                {<BR>
                  alert('The Password and verified password does not match!');<BR>
                  return false;<BR>
                }<BR>
                else<BR>
                {<BR>
                  return true;<BR>
                }<BR>
              }<BR>
         </CODE><br>
         <LI type="disc">Associate the validation function with the validator object.<br>
         <CODE>
         frmvalidator.setAddnlValidationFunction("DoCustomValidation");
         </CODE><br>
         </LI>
         <P>
         The custom validation function will be called automatically after other validations.
         </P>
         <P>
         If you want to do more than one custom validations, you can do all those
         validations in the same function.
         </P>
         <CODE>
              function DoCustomValidation()<BR>
              {<BR>
                var frm = document.forms["myform"];<BR>
                if(false == DoMyValidationOne())<BR>
                {<BR>
                  alert('Validation One Failed!');<BR>
                  return false;<BR>
                }<BR>
                else<BR>
                if(false == DoMyValidationTwo())<BR>
                {<BR>
                  alert('Validation Two Failed!');<BR>
                  return false;<BR>
                }<BR>
                else<BR>
                {<BR>
                  return true;<BR>
                }<BR>
              }<BR>
         </CODE><br>
         where DoMyValidationOne() and DoMyValidationTwo() are custom functions for
         validation.
         <A name="6"></A>
         <h3>Clear All Validations</h3>
         In some dynamically programmed pages, it may be required to change the validations in the
         form at run time. For such cases, a function is included which clears all validations in the
         validator object.<br><br>
         <CODE>
         frmvalidator.clearAllValidations();
         </CODE><br>
         <br>
         this function call clears all validations you set.<br>
         You will not need this method in most cases.
         <a name="7"></a>
         <h3>Table of Validation Descriptors</h3>     
    <table cellspacing="2" cellpadding="2" border="1" width="520px">
    <tr>
    <td><FONT face=Arial size=2>
         required<BR>
         req </FONT>
         </td>
    <td><FONT face=Arial size=2>The field should not be
    empty </FONT>
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>
         maxlen=???<BR>
         maxlength=???
         </td>
    <td><FONT face=Arial size=2>checks the length entered data to the maximum. For
    example, if the maximum size permitted is 25, give the validation descriptor as "maxlen=25"
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>
         minlen=???<BR>
         minlength=???
         </td>
    <td><FONT face=Arial size=2>checks the length of the entered string to the
    required minimum. example "minlen=5"
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>
         alphanumeric /<BR>
         alnum </FONT>
         </td>
    <td><FONT face=Arial size=2>Check the data if it
    contains any other characters other than alphabetic or numeric characters
    </FONT>
         </td>
    </tr>     
    <tr>
    <td><FONT face=Arial size=2>num <BR>
         numeric </FONT>
         </td>
    <td><FONT face=Arial size=2>Check numeric data
    </FONT>
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>alpha <BR>
         alphabetic </FONT>
         </td>
    <td><FONT face=Arial size=2>Check alphabetic data.
    </FONT>
         </td>
    </tr>     
    <tr>
    <td><FONT face=Arial size=2>email </FONT>
         </td>
    <td><FONT face=Arial size=2>The field is an email
    field and verify the validity of the data. </FONT>
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>lt=???<BR>
         lessthan=???
         </td>
    <td><FONT face=Arial size=2>
         Verify the data to be less than the value passed.
         Valid only for numeric fields. <BR>
         example: if the
    value should be less than 1000 give validation description as "lt=1000"
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>gt=???<BR>
         greaterthan=???     </td>
    <td><FONT face=Arial size=2>
         Verify the data to be greater than the value passed.
         Valid only for numeric fields. <BR>
         example: if the
    value should be greater than 10 give validation description as "gt=10"
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>regexp=??? </FONT>
         </td>
    <td><FONT face=Arial size=2>
         Check with a regular expression the value should match the regular expression.<BR>
         example: "regexp=^[A-Za-z]{1,20}$" allow up to 20 alphabetic
         characters.
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>dontselect=?? </FONT>
         </td>
    <td><FONT face=Arial size=2>This
    validation descriptor is valid only for select input items (lists)
    Normally, the select list boxes will have one item saying 'Select One' or
    some thing like that. The user should select an option other than this
    option. If the index of this option is 0, the validation description
    should be "dontselect=0"
         </td>
    </tr>
    </table>
         <P>
              <table cellspacing="2" cellpadding="2" border="1" width="520">
              <tr>
              <td>
                   <B>NOTE:</B><br>
                   The HTML Form Wizard included in JavaScript Coder contains still more
                   number of validations
                   (comparison validations, check box & radio button validations and more)<br>
                   Using the wizard, you can add validations to your forms
                   without writing a single line of code! <br>
                   JavaScript Coder takes care of
                   generating the code and inserting the code in to the HTML file.<br>
                   <A href="http://www.javascript-coder.com/index.phtml
                   target="_blank">Read more about JavaScript Coder</A>
                   </td>
              </tr>
              </table>
         </P>
         <A name="8"></A>
         <h3>Example Page</h3>     
         See the <a href="example.html target="_blank"
         >JavaScript form validation example here</a>
    </td>
    </tr>
    <tr><td align="center">
         <HR><br>
         Copyright &copy; 2003 JavaScript-Coder.com. All rights reserved.
    </td></tr>
    </table>     
    </center>
    </body>
    </html>

    The code is not working because you made a mistake somewhere, duh! So figure out what (hint: firefox javascript console, it's your friend) and fix it!
    And next time when you post code: use the [ code ]  tags to pretty format your code, as it is now it's unreadable.
    http://forum.java.sun.com/help.jspa?sec=formatting

  • Eggtimer or something like that

    hi guys,
    i have a page that when i submit takes a while to process a load of things like uploading data to a database etc....
    i was wondering the possiblity of displaying an egg timer something cool like that to notify the user that it hasnt hung and is still working away...any ideas?
    can this be done using javascripts onsubmit somehow?
    any pointers to things i can do...i know there is a sort of progress bar in internet explorer at the bottom but was hopign for somehting bette than this,
    cheers guys
    AndyT

    This topic has a few solutions. http://forum.java.sun.com/thread.jspa?forumID=45&threadID=554223
    I think still more hang around the internet and these forums, if you did a google search and/or a Forum search using progress bar, 'Please Wait', or similar things as your search criteria

  • Upload files using browser

    how is posible upload files using a browser (IE5) to BD ?

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by JuanCarlos HorrachCampins (jchorrach@globalia:
    how is posible upload files using a browser (IE5) to BD ?<HR></BLOCKQUOTE>
    The Form enctype=multipart/formdata and input type=file parameters are needed along with method=post.
    You then need a servlet(or MS PostingAcceptor) on the server side to read/store it. The Post data is in multiple parts with the parms on separate lines..
    Here is sample HTML Form:
    <HTML>
    <BODY>
    <H2>Uplaod test </H2>
    <form enctype="multipart/form-data" action="/examples/servlet/MultipartForm"
    METHOD="POST"
    NAME="UploadFileForm"
    LANGUAGE="JavaScript"
    onSubmit="if (!validateForm(document.UploadFileForm))
    alert ('Please enter a fileName.');
    document.UploadFileForm.my_file.select();
    return false;
    }">
    <input type="text" name="TargetURL" value="/uploads">
    <input type="text" name="submitter" value="me">
    <FIELDSET> <legend> FileUpload</legend>
    <BR>
    <table>
    <tr>
    <td align="left">Fully qualified Filename to upload:</td>
    </tr>
    <tr>
    <td align="left"><input name="file" type="file" size="50"></td>
    </tr>
    <tr>
    <td align="left"><input type="Submit" value="Upload File"></td>
    </tr>
    <table>
    </FIELDSET>
    </form>
    <SCRIPT LANGUAGE="JavaScript">
    // Begin client side helper functions
    function validateForm(form)
    if (isEmpty(form.file)) return false;
    return true;
    function isEmpty(textcontrol)
    str = textcontrol.value
    for (i = 0; i < str.length; i++)
    chr = str.substring(i, i + 1);
    if (chr != ' ')
    return false;
    return true;
    </SCRIPT>
    </BODY>
    </HEAD>
    null

  • Auto-validation does not work on MX7

    Since I upgraded to CF MX7 auto-validation on my cfinput
    forms stops working,
    if I have my custom Javascript onSubmit handler
    Example:
    <script language="javascript">
    function checkFields() {
    alert('This validation should occurred after the CF
    validation.');
    </script>
    <body>
    <cfform id="form1" name="myForm" method="post"
    onSubmit="return checkFields()" action="">
    <table width="215" border="1">
    <tr>
    <td width="205">
    <cfinput type="text" name="float" message="float datatype"
    validate="float"/>
    float </td>
    </tr>
    <tr>
    <td><label>
    <cfinput type="text" name="date" message="date datatype"
    validate="date" />
    date</label></td>
    </tr>
    <tr>
    <td><input type="submit" name="button" id="button"
    value="Submit" /></td>
    </tr>
    </table>
    </cfform>
    Please advise
    Thanks

    Hello there, Josiahfromvt.
    Great job so far with troubleshooting the auto-brightness on your iPhone. After making sure you have backed up your device, you may want to use the following Knowledge Base article to setup the phone as new to test one last time:
    Use iTunes to restore your iOS device to factory settings
    http://support.apple.com/kb/ht1414
    Once it is restored as new, you can review the steps found here:
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/ts2802
    Display doesn't adjust brightness automatically
    The ambient light sensor brightens the display when using the iPhone in brightly lit environments, and dims the display in low light. To test this sensor, do the following:
    If the iPhone is in a protective case, remove it from the case. If there is a protective film on the display, remove the film.
    Verify that the Auto-Brightness setting (Settings > Brightness and Wallpaper) is set to ON, and that the Brightness level is set near the middle of the slider.
    Press the Home button to return to the Home screen and then press the Sleep/Wake button to lock the iPhone.
    In a bright environment, cover the top third of the iPhone to block the light, then press the Sleep/Wake button or the Home button to wake the phone. Slide the slider to unlock the phone.
    Notice the brightness of the screen and application icons; they should be somewhat dimmed.
    Remove the cover from the top of the display and in a few moments the display should get brighter.
    My issue is still not resolved. What do I do next?
    Contact Apple Support.
    If you need to restore your device with your previous settings, the following article reviews how to restore from both iCloud or iTunes:
    iOS: Back up and restore your iOS device with iCloud or iTunes
    http://support.apple.com/kb/ht1766
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • In a javascript function invoked from an onsubmit handler, if the function returns false, the form is still submitted. If I find an error in a form, how do I cancel the submit?

    HTML form has: action="/TTFFRP/addlicense.rex" method="get" onsubmit="validate_data();"
    validate_data is defined in tags:
    function validate_data()
    alert('in validate routine');
    if (document.getElementById('custname').value == '')
    alert('Customer name must not be blank; put in name of organization licensing File RePackager');
    return false;
    }

    Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The helpers over there are more knowledgeable about web page development issues with Firefox.
    [http://forums.mozillazine.org/viewforum.php?f=25]
    You'll need to register and login to be able to post in that forum.

  • 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

  • Passing JavaScript value to Jsp

    Hi,
    Any idea how to pass a value from javascript to jsp page when the page gets load on browser.
    I use below code but an event is require to pass the value. Is there any code that pass automatically the value from javascript to jsp.
    <html>
    <head>
    <title>Passing Javascript value to Jsp</title>
    <script type="text/javascript" language="javascript">
    var scriptVar = "Noy"
    var WinNetwork = new ActiveXObject("WScript.Network")
    document.write (WinNetwork.username)
    document.index.hiddenTextBox.value = WinNetwork.username
    </script>
    </head>
    <%
    String jspVar = null;
    if(request.getParameter("submit") != null){
         jspVar = request.getParameter("hiddenTextBox");
         out.println("Jsp Var : " + jspVar);
    %>
    <body>
    <form name="index" onSubmit="index.jsp" method="post">
    <input type="hidden" name="hiddenTextBox"><br>
    <input type="submit" name="submit" value="Submit">
    </form>
    </body>
    </html>
    Thanks,
    ~ukbasak

    JSP/Java runs at the server side, produces a HTML page, sends it to the client side and then stops running.
    HTML, containing under each CSS and JS, arrives at the client side and runs at the client side only.
    To invoke JSP/Java using HTML you need to fire a request to the server side. That can be either a plain vanilla <a> link, a <form> to be submitted or an asynchronous Ajaxical request.
    That said, the use of ActiveX in web applications is discouraged. It's a Microsoft IE proprietaty. With other words, it isn't and won't be supported by all alternative browsers which the other half of the world is using.

  • How do I centre javascript in a HTML page? Please help!

    Ok, I recently set up a website with advertising space. The space is split into banner engines of 10 banners each rotating every 7 seconds.
    I have fully tested the coding which I downloaded and it all seems to work as well as I need it to.
    The only problem that I have is that the javascript or at least the banner it produces are always firmly stuck to the left. They need to mbe in the centre to fit the rest of the page, but I can't seem to get them to centre.
    Here's how the page is set up and coded:
    in the page I have:<html>
    <head>
    <center>
    <p>Each test banner links back to this page. Your banner would link to whatever site/location you required.</p>
    <p>
    <script type=text/javascript src="http://www.UkVariety.co.uk/banner/div_construct2.js"></script>
    <script type=text/javascript>
    var _banners = new Array();
    function addBanner(_bannerHTML){
      _banners[_banners.length?_banners.length:0]=_bannerHTML;
    addBanner("<a href='http://www.ukvariety.co.uk/banners.html'><img border=0 alt='Advertiser 1' src='http://www.ukvariety.co.uk/Images/banners/Ad1.gif'></a>");
    addBanner("<a href='http://www.ukvariety.co.uk/banners.html'><img border=0 alt='Advertiser 2' src='http://www.ukvariety.co.uk/Images/banners/Ad2.gif'></a>");
    addBanner("<a href='http://www.ukvariety.co.uk/banners.html'><img border=0 alt='Advertiser 3' src='http://www.ukvariety.co.uk/Images/banners/Ad3.gif'></a>");
    addBanner("<a href='http://www.ukvariety.co.uk/banners.html'><img border=0 alt='Advertiser 4' src='http://www.ukvariety.co.uk/Images/banners/Ad4.gif'></a>");
    addBanner("<a href='http://www.ukvariety.co.uk/banners.html'><img border=0 alt='Advertiser 5' src='http://www.ukvariety.co.uk/Images/banners/Ad5.gif'></a>");
    addBanner("<a href='http://www.ukvariety.co.uk/banners.html'><img border=0 alt='Advertiser 6' src='http://www.ukvariety.co.uk/Images/banners/Ad6.gif'></a>");
    addBanner("<a href='http://www.ukvariety.co.uk/banners.html'><img border=0 alt='Advertiser 7' src='http://www.ukvariety.co.uk/Images/banners/Ad7.gif'></a>");
    addBanner("<a href='http://www.ukvariety.co.uk/banners.html'><img border=0 alt='Advertiser 8' src='http://www.ukvariety.co.uk/Images/banners/Ad8.gif'></a>");
    addBanner("<a href='http://www.ukvariety.co.uk/banners.html'><img border=0 alt='Advertiser 9' src='http://www.ukvariety.co.uk/Images/banners/Ad9.gif'></a>");
    addBanner("<a href='http://www.ukvariety.co.uk/banners.html'><img border=0 alt='Advertiser 10' src='http://www.ukvariety.co.uk/Images/banners/Ad10.gif'></a>");
    var div2 = new NewDiv2(window, "banner", _banners[0],0,0,50,50,500,"ABSOLUTE");
    var count=0; /* which one to start with */
    function doIt() {
    count++;
    count%=_banners.length;
    div2.setBody(_banners[count]);
    setInterval('doIt()',7000);
    </script>
    </p>
    </head>
    <body>
    <script type=text/javascript>
    div2.output();
    </script>
    </body></center>
    </html>The javascript links to a file caled div_construct2.js
    This file contains the following coding:
    isNS = document.layers?true:false;
    isIE = navigator.appName.indexOf("Microsoft") != -1
    isNS6=document.getElementById&&!isIE?true:false;
    function NewDiv2(window, id, body, left, top, width, height, zIndex, absolute) {
        this.window = window;
        this.id     = id;
        this.body   = body;
        var d = window.document;
        d.writeln('<STYLE TYPE="text/css">#' + id + ' {');
         if (absolute) d.write('position:absolute;');
         else          d.write('position:relative;');
        if (left)   d.write('left:'  + left  + ';');
        if (top)    d.write('top:'   + top   + ';');
        if (width)  d.write('width:' + width + ';');
         if (height) d.write('height:' + height + ';');
         if (zIndex) d.write('z-index:' + zIndex + ';');
        d.writeln('}</STYLE>');
    if (isNS) {
        NewDiv2.prototype.output             = function()      { var d = this.window.document;d.writeln('<DIV ID="' + this.id + '">');d.writeln(this.body);d.writeln("</DIV>");this.layer = d[this.id];}
        NewDiv2.prototype.moveTo             = function(x,y)   { this.layer.moveTo(x,y); }
        NewDiv2.prototype.moveBy             = function(x,y)   { this.layer.moveBy(x,y); }
        NewDiv2.prototype.show               = function()      { this.layer.visibility = "show"; }
        NewDiv2.prototype.hide               = function()      { this.layer.visibility = "hide"; }
        NewDiv2.prototype.setZ               = function(z)     { this.layer.zIndex = z; }
        NewDiv2.prototype.setBgColor         = function(color) { this.layer.bgColor = color; }
        NewDiv2.prototype.setBgImage         = function(image) { this.layer.background.src = image;}
        NewDiv2.prototype.getX               = function() { return this.layer.left; }
        NewDiv2.prototype.getY               = function() { return this.layer.top; } //was right .. ??
        NewDiv2.prototype.getWidth           = function() { return this.layer.width; }
        NewDiv2.prototype.getHeight          = function() { return this.layer.height; }
        NewDiv2.prototype.getZ               = function() { return this.layer.zIndex; }
        NewDiv2.prototype.isVisible          = function() { return this.layer.visibility == "show"; }
        NewDiv2.prototype.setBody            = function() { for(var i = 0; i < arguments.length; i++) this.layer.document.writeln(arguments);this.layer.document.close();}
    NewDiv2.prototype.addEventHandler = function(eventname, handler) {this.layer.captureEvents(NewDiv2._eventmasks[eventname]); var newdivel = this;this.layer[eventname] = function(event) { return handler(newdivel, event.type, event.x, event.y, event.which, event.which,((event.modifiers & Event.SHIFT_MASK) != 0),((event.modifiers & Event.CTRL_MASK)  != 0),((event.modifiers & Event.ALT_MASK)   != 0));}}
    NewDiv2.prototype.removeEventHandler = function(eventname) {this.layer.releaseEvents(NewDiv2._eventmasks[eventname]);delete this.layer[eventname];}
    NewDiv2.prototype.centerX = function() {this.layer.moveTo(Math.round((window.pageXOffset+document.width-100)/2),this.layer.top)}
    NewDiv2._eventmasks = {onabort:Event.ABORT,onblur:Event.BLUR,onchange:Event.CHANGE,onclick:Event.CLICK,ondblclick:Event.DBLCLICK, ondragdrop:Event.DRAGDROP,onerror:Event.ERROR, onfocus:Event.FOCUS,onkeydown:Event.KEYDOWN,onkeypress:Event.KEYPRESS,onkeyup:Event.KEYUP,onload:Event.LOAD,onmousedown:Event.MOUSEDOWN,onmousemove:Event.MOUSEMOVE, onmouseout:Event.MOUSEOUT,onmouseover:Event.MOUSEOVER, onmouseup:Event.MOUSEUP,onmove:Event.MOVE,onreset:Event.RESET,onresize:Event.RESIZE,onselect:Event.SELECT,onsubmit:Event.SUBMIT,onunload:Event.UNLOAD};
    if (isIE) {
    NewDiv2.prototype.output = function() { var d = this.window.document;d.writeln('<DIV ID="' + this.id + '">');d.writeln(this.body);d.writeln("</DIV>");this.element = d.all[this.id];this.style = this.element.style;}
    NewDiv2.prototype.moveTo = function(x,y) { this.style.pixelLeft = x;this.style.pixelTop = y;}
    NewDiv2.prototype.moveBy = function(x,y) { this.style.pixelLeft += x;this.style.pixelTop += y;}
    NewDiv2.prototype.show = function() { this.style.visibility = "visible"; }
    NewDiv2.prototype.hide = function() { this.style.visibility = "hidden"; }
    NewDiv2.prototype.setZ = function(z) { this.style.zIndex = z; }
    NewDiv2.prototype.setBgColor = function(color) { this.style.backgroundColor = color; }
    NewDiv2.prototype.setBgImage = function(image) { this.style.backgroundImage = image;}
    NewDiv2.prototype.getX = function() { return this.style.pixelLeft; }
    NewDiv2.prototype.getY = function() { return this.style.pixelRight; }
    NewDiv2.prototype.getWidth = function() { return this.style.width; }
    NewDiv2.prototype.getHeight = function() { return this.style.height; }
    NewDiv2.prototype.getZ = function() { return this.style.zIndex; }
    NewDiv2.prototype.isVisible = function() { return this.style.visibility == "visible"; }
    NewDiv2.prototype.setBody = function() { var body = "";for(var i = 0; i < arguments.length; i++) {body += arguments[i] + "\n";}this.element.innerHTML = body;}
    NewDiv2.prototype.addEventHandler = function(eventname, handler) { var NewDiv = this;this.element[eventname] = function() { var e = NewDiv2.window.event;e.cancelBubble = true;return handler(NewDiv2, e.type, e.x, e.y, e.button, e.keyCode, e.shiftKey, e.ctrlKey, e.altKey); }}
    NewDiv2.prototype.removeEventHandler = function(eventname) { delete this.element[eventname];}
         NewDiv2.prototype.centerX = function() { this.style.pixelLeft=Math.round((document.body.clientWidth+document.body.scrollLeft-300)/2)}
    * The following was written by:
    * Dario Guzik
    * Spam unfriendly email address: dguzik AT bigfoot DOT com
    if (isNS6) {
    NewDiv2.prototype.output = function() { var d = this.window.document;d.writeln('<DIV ID="' + this.id + '">');d.writeln(this.body);d.writeln("</DIV>");this.element = d.getElementById(this.id);this.style = this.element.style;}
    NewDiv2.prototype.moveTo = function(x,y) { this.style.pixelLeft = x;this.style.pixelTop = y;}
    NewDiv2.prototype.moveBy = function(x,y) { this.style.pixelLeft += x;this.style.pixelTop += y;}
    NewDiv2.prototype.show = function() { this.style.visibility = "visible"; }
    NewDiv2.prototype.hide = function() { this.style.visibility = "hidden"; }
    NewDiv2.prototype.setZ = function(z) { this.style.zIndex = z; }
    NewDiv2.prototype.setBgColor = function(color) { this.style.backgroundColor = color; }
    NewDiv2.prototype.setBgImage = function(image) { this.style.backgroundImage = image;}
    NewDiv2.prototype.getX = function() { return this.style.pixelLeft; }
    NewDiv2.prototype.getY = function() { return this.style.pixelRight; }
    NewDiv2.prototype.getWidth = function() { return this.style.width; }
    NewDiv2.prototype.getHeight = function() { return this.style.height; }
    NewDiv2.prototype.getZ = function() { return this.style.zIndex; }
    NewDiv2.prototype.isVisible = function() { return this.style.visibility == "visible"; }
    NewDiv2.prototype.setBody = function() { var body = "";for(var i = 0; i < arguments.length; i++) {body += arguments[i] + "\n";}this.element.innerHTML = body;}
    NewDiv2.prototype.addEventHandler = function(eventname, handler) { var NewDiv = this;this.element[eventname] = function() { var e = NewDiv2.window.event;e.cancelBubble = true;return handler(NewDiv, e.type, e.x, e.y, e.button, e.keyCode, e.shiftKey, e.ctrlKey, e.altKey); }}
    NewDiv2.prototype.removeEventHandler = function(eventname) { delete this.element[eventname];}
    NewDiv2.prototype.centerX = function() { this.style.pixelLeft=Math.round((document.body.clientWidth+document.body.scrollLeft-300)/2)}
    If anyone could help, I would be most grateful and could even offer a free advert for a while if needs be.
    Thanks in advance
    Dave
    "I think my brain exploded"

    You might want to ask this on a JavaScript forum.
    Java and JavaScript are not related.Now his brain probably experienced not just a mere explosion, but more like an atomic one.

  • Alert message in javascript if drop down in 1 column is blank and other column is not blank

    What I’m trying to do is have a java window alert pop up if the PNR column is blank and the BOM column is not blank on each row. I also put a cold fusion If statement around this javascript that the CN_Entry column in the Items table has to be an “N”. This code all actually works, but it only works on the row with the latest or newest item with an “N” in the CN_Entry column. I would like this to work on every row, so that if someone does this on any row, or multiple rows, this alert box will keep popping up until all the conditions are satisfied. What do I need to change to make this javascript work? Thanks.
    <cfif CN_Entry EQ "N">
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function verify() {
    var themessage = "Please enter ";
    if (EditItem.PNR_Approval_Initials#ItemID#.selectedIndex == 0 && EditItem.BOM_Approval_Initials#ItemID#.selectedIndex > 0)
    alert("You must enter some PNR initials for ECO #ECID_SPEC# Part Number: #Part_Number#");
    EditItem.PNR_Approval_Initials#ItemID#.focus();
    return (false);
    else
    document.EditItem.submit();
    //  End -->
    </script>
    </cfif>
    Andy

    The first thing you have to do is to remove the ColdFusion conditional logic.  ColdFusion runs on the server.  JS runs on the client.
    The next thing is to call the function from an event that happens on the web page.  form onsubmit seems like a good choice.

  • How do i call servlet from javascript after validation the javascript

    Hi ,
    Can anyone tell me how to call a servlet after the javascript is being validated. Here is my code to validate javascript i need to call a servlet inorder to save the data into the same form. I tried calling through the action method in the form but its directly taking me to the servlet but not validating the form. Is there any way that i can validate the form first then call the servlet.
    Thanks in advance.
    <html>
    <head>
    <title>Online Blog</title>
    <script language ="javascript" type ="text/javascript">
    function myfunction()
    var mesg = "";
    var dmesg = "";
    var dnumber = 0;
    var number = 0
    var Blogstr = document.onlineblog.BlogName;
    var Fnamestr = document.onlineblog.FirstName;
    var Lnamestr = document.onlineblog.LastName;
    var Datestr = document.onlineblog.Dateformat;
    var Imagestr = document.onlineblog.uploadimage;
    var Imageval = Imagestr.value;
    var flength = parseInt(Imageval.length) - 3;
    var fext = Imageval.substring(flength,flength + 3);
    var Dateval = Datestr.value;
    var Dformat = /^\d{2}\/\d{2}\/\d{4}/; //checks the date format.
    //splits date into mm, dd , yyyy format.
    var m = Dateval.split("/")[0];
    var d = Dateval.split("/")[1];
    var y = Dateval.split("/")[2];
    //Get today's date (removes time).
    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth()+1;
    var yyyy = today.getFullYear();
    //checks if month and date are displayed in mm, dd format and if not sets to mm,dd.
    if (mm <10)
    mm = '0'+mm;
    if (dd <10)
    dd = '0'+dd;
    //checks if name of the blog is empty
    if(Blogstr.value == "")
    number = number+1;
    mesg += "\n" + number + "Name of the blog";
    //checks if value of Frist Name is empty;
    if(Fnamestr.value == "")
    number = number+1;
    mesg += "\n" + number + "First Name";
    //checks if value of Last Name is empty;
    if(Lnamestr.value == "")
    number = number+1;
    mesg += "\n" + number + "Last Name";
    //checks if value of date is empty;
    if(Datestr.value == "")
    number = number+1;
    mesg += "\n" + number + "Date of mm/dd/yyyy format";
    //checks if value of image field is empty;
    if(Imagestr.value == "")
    number = number+1;
    mesg += "\n" + number + "select an image";
    //displays all the error messages.
    if (number > 0)
    alert ("Please enter the following" + mesg);
    return false;
    //checks if entered date format is mm/dd/yyyy
    if(!Dformat.test(Dateval))
    dnumber = dnumber +1;
    dmesg += "\n" + dnumber + "please enter a valid date(mm/dd/yyyy)";
    //checks if date is greater than 12 and is 2 digits.
    if ((m>12 && m<100) || (m> = 100 && m<1000) || (m==0))
    dnumber = dnumber+1;
    dmesg += "\n" + dnumber + "Enter valid month(mm)";
    //checks if month has 31 or 30 days and is in dd format.
    if (((d>30) && (d<100) && (m == 04 || m == 06 || m == 9 || m == 11)) || ((m == 01 || m == 03 || m == 05 || m == 07 || m == 08 || m == 10 || m==12) && (d >31) && (d<100)) || d == 0)
    dnumber = dnumber+1;
    dmesg += "\n" + dnumber + "Enter valid date(dd)";
    //checks if month has 28 or 29 days and wheather is a leap year or not.
    if((m == 02 && d>29 && y%4 == 0) || (m == 02 && d>28 && y%4 != 0))
    dnumber = dnumber+1;
    dmesg += "\n" + dnumber + "Enter valid date(dd)";
    //checks if entered date is prior to the current date.
    if((m == mm && d == dd && y == yyyy) || (y > yyyy)|| (d>=dd && m>=mm && m<=12 && y==yyyy) || (d<=dd && m>mm && y == yyyy && m<=12))
    dnumber = dnumber + 1;
    dmesg += "\n" + dnumber + "Please enter a date prior to the current date";
    if (y == 0 || y < 1000 || y>9999) //checks if year is zero and is a 4 digit number.
    dnumber = dnumber + 1;
    dmesg += "\n" + dnumber + "Enter a valid year(yyyy)";
    //checks if image format is jpg or gif.
    if(fext != "jpg" && fext != "gif")
    dnumber = dnumber + 1
    dmesg += "\n" + dnumber + "You can only upload gif or jpg images.";
    if(dnumber>0)
    alert("please check the followin error messages"+dmesg);
    return false;
    </script>
    <style type="text/css">
    .style1 {color: #FF0000}
    body {
         background-color: #FFCCFF;
    h2 {
         color: #CC3399;
    h1 {
         color: cc3399;
    .style2 {
         font-family: Arial, Helvetica, sans-serif;
         font-weight: bold;
    .style5 {color: #000000; font-family: "Times New Roman", Times, serif;}
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><body>
    <h1 align="center">Webloggers space</h1>
    <p align="center">Home
    <p>
    <h4> Please enter the following details to register.</h4>
    <p> <b>Note:</b> All fields marked with <span class="style1">*</span>(astrick)
    are compulsory.</p>
    <form action="servlet/BlogServlet" name="onlineblog" onsubmit = "return myfunction()" method="post">
    <table width="60%" border="0" cellspacing="5" cellpadding="2">
    <tr>
    <td><span class="style1">*</span>Name of the Blog</td>
    <td><input type="text" name="BlogName"/></td>
    </tr>
    <tr>
    <td><span class="style1">*</span>First Name</td>
    <td><input type="text" name="FirstName"/></td>
    </tr>
    <tr>
    <td><span class="style1">*</span>Last Name</td>
    <td><input type="text" name="LastName"/></td>
    </tr>
    <tr>
    <td><span class="style1">*</span>Date(mm/dd/yyyy)</td>
    <td><input type="text" name="Dateformat"/></td>
    </tr>
    <tr>
    <td>Category</td>
    <td><select name="catagory" size="1">
    <option></option>
    <option>Business</option>
    <option>Education</option>
    <option>Entertainment</option>
    <option>Food</option>
    <option>Hobbies</option>
    <option>Personal</option>
    <option>Politics</option>
    <option>Sports</option>
    </select></td>
    </tr>
    <tr>
    <td>Enter your text here:</td>
    <td><textarea name="textarea" cols="45" rows="5"></textarea></td>
    </tr>
    <tr>
    <td><span class="style1">*</span>Upload Image <span class="style5">(.jpg
              or .gif)</span></td>
    <td><input type="file" name="uploadimage" /></td>
    </tr>
    <tr>
    <td></td>
    <td><input type="submit" value="save">
    <input type="reset" name="reset" value="Reset" /></td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    Your javascript code contains a syntax error. That's why the function isn't being called. Take a look at this line in your code.
    if ((m>12 && m<100) || (m> = 100 && m<1000) || (m==0))Notice the space between > and =. Remove that space.
    m >= 100

  • Using Javascript to require 2 drop down menus to have something selected

    Hi everyone. I'm trying to get 2 drop down menus to each have something selected when the form is submitted. I'm using javascript for this, but I can't get it to work. Basically, if one is blank and the other one isn't, I want an error to pop up saying they have to fill in the one that is blank and vice versa. What am I doing wrong? Here's what I have for the javascript and on the form below. My 2 drop down names are Mfg_Spec_Prod_Approval_Initials and Mfg_Spec_Prod_Approval_Rev. Thanks for anyone's help!
    Andy
    <SCRIPT LANGUAGE="JavaScript">
            function verify() {
                var partNumber = '';
                var ecoNumber = '';
                var ProdInit;
                var ProdInitValue='';
                var ProdRev;
                var ProdRevValue='';
                var allArray = document.getElementById('listofids').value.split(",");
                var error=false;
                for(var i=0;i<allArray.length;i++) {
                    ProdRev = document.getElementById('Mfg_Spec_Prod_Approval_Rev'+allArray[i]);
                    ProdInit = document.getElementById('Mfg_Spec_Prod_Approval_Initials'+allArray[i]);
                    ProdRevValue = ProdRev[ProdRev.selectedIndex].value;
                    ProdInitValue = ProdInit[ProdInit.selectedIndex].value;
    <!--- This code is if the BOM Initials is not empty and the PNR Initials is empty.--->
                    if(ProdInitValue != '' && ProdRevValue == '') {
                        error=true;
                        ecoNumber = document.getElementById('ECID'+allArray[i]).value;
                        partNumber = document.getElementById('Part_Number'+allArray[i]).value;
                        alert("You must enter a Rev for ECO " + ecoNumber + " Part Number: " + partNumber);
                    else if(ProdRevValue != '' && ProdInitValue == '') {
                        error=true;
                        ecoNumber = document.getElementById('ECID'+allArray[i]).value;
                        partNumber = document.getElementById('Part_Number'+allArray[i]).value;
                        alert("You must enter your initials for ECO " + ecoNumber + " Part Number: " + partNumber);
                if(error) {
                return false;
            else {
                return true;
        </script>
    Start of form
    <cfform name="EditItem" method="post" action="My_Machining_action.cfm" onsubmit="return verify();">
    <cfset MfgSpecProdInitials = DocumentationSearch.Mfg_Spec_Prod_Initials>
    <td align="center">
    <cfif Mfg_Spec_Prod_Initials Is Not ""<!---  and Mfg_Spec_Prod_Initials EQ cookie.UserInitials --->>
    <select name="Mfg_Spec_Prod_Approval_Initials#ItemID#" id="Mfg_Spec_Prod_Approval_Initials#ItemID#">
    <option value=""></option>
    <cfloop query="ShowProdInitials">
    <option value="#Initials#"
    <cfif #Initials# EQ MfgSpecProdInitials>selected</cfif>>#Initials#</option>
    </cfloop>
    </select>
    <cfelse>
    </cfif>
    </td>
    <cfset MfgSpecProdRev = DocumentationSearch.Mfg_Spec_Prod_Rev>
    <td align="center">
    <cfif Mfg_Spec_Prod_Initials Is Not ""<!---  and Mfg_Spec_Prod_Initials EQ cookie.UserInitials --->>
    <select name="Mfg_Spec_Prod_Approval_Rev#ItemID#" id="Mfg_Spec_Prod_Approval_Rev#ItemID#">
    <option value=""></option>
    <cfloop query="ShowDocRevChoices">
    <option value="#Doc_Rev_Initials#"
    <cfif #Doc_Rev_Initials# EQ MfgSpecProdRev>selected</cfif>>#Doc_Rev_Initials#</option>
    </cfloop>
    </select>
    <cfelse>
    </cfif>
    </td>
    <input type="submit" value="Update">

    Eddie,
       I actually got this javascript below to work so if one drop down is left blank, and the other one is filled out, an error will pop up saying to entering either some initials or a rev. The only problem is that I have a dynamic list of drop downs in rows, so I need this javascript to run for each row. If I do the 1st row with 1 drop down selected and the other not, it gives me the error, which is perfect. But if I want the 2nd row to error out, for instance, doing the same thing, the error will not pop up. How do I make this work so it does this for each row since the list of drop downs is dynamic? My drop down menu names are Mfg_Spec_Prod_Approval_Initials and Mfg_Spec_Prod_Approval_Rev.
    <script type="text/javascript">
                        function verify() {
                            var Mfg_Spec_Prod_Approval_Initials = document.getElementById('Mfg_Spec_Prod_Approval_Initials');
                            var Mfg_Spec_Prod_Approval_Rev = document.getElementById('Mfg_Spec_Prod_Approval_Rev');
                            if(Mfg_Spec_Prod_Approval_Initials.selectedIndex == '' && Mfg_Spec_Prod_Approval_Rev.selectedIndex != '') {
                                alert('select Initials!');
                                return false;
      else if(Mfg_Spec_Prod_Approval_Rev.selectedIndex == '' && Mfg_Spec_Prod_Approval_Initials.selectedIndex != '') {
                                alert('select a Rev!');
                                return false;
                            return true;
                    </script>
    Andy

  • OnSubmit of FORM not working in Tomcat/5.5.9..........

    hello
    I am a starter in JSP and I decided 2 try dis code out but it never works on my tomcat..... I browsed d internet for some form validadtion scripts and dey 2 didnt worked on d tomca.... Heres d code pls tell me whts d problem is ..
    <%@ page language="java" session="true" %>
    <html>
    <script language="JavaScript">
    function check_email()
         String email_id=document.prodform.email.value;
         out.println("Please Wait Checking");
         if(email_id==null)
              return false;
              return true;
    </script>
    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    </head>
    <body>
    <form onsubmit="return check_email()" action="valid.jsp" method="get">
    <p><input type="text" size="20" name="email">
    <input type="submit" value="SUBMIT" name="Submit">
    </form>
    </body>
    </html>
    P.S - "----" are excluded in d original code.
    Super Thanx in Advance

    CODE IS REFORMATTED HERE
    <%@ page language="java" session="true" %>
    <script language="JavaScript">
    function check_email() {
    String email_id=document.prodform.email.value;
    out.println("Please Wait Checking");
    if(email_id==null)
    return false;
    return true;
    </script>
    <head> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    </head>
    <body>
    <form onsubmit="return check_email()" action="valid.jsp" method="get">
    <input type="text" size="20" name="email">
    <input type="submit" value="SUBMIT" name="Submit">
    </form>
    </body>
    </html>

  • CFFORM onSubmit script works in FF but not in IE

    I've got a CFFORM that has an onSubmit additional javascript for  form validation, and while it works in FF, it passes right through in IE and ends up erroring because the mandatory fields aren't there...
    the CFFORM call looks like this
    <cfform name="add_project" method="post" action="xxxxxxx.cfm?view=admin-add-process&entity=project" enctype="multipart/form-data" onsubmit="return checkReq();">
    and the function looks like
    <script language="javascript">
    function checkReq() {
    var valid = true;
    var errMsg = '';
    if (document.add_project.projectreviewer_emails.value.trim() == '') {
    } else {
    </script>
    Any ideas?
    Thanks in advance,
    bw

    There is some doubt regarding the universality of Javascript's trim function among browsers. Is it vital here?  If you leave it out, your code will work across all browsers. Something along the lines of:
    <script type="text/javascript">
    function checkReq() {
        var valid = true;
        var errMsg = '';
        var projectReviewerEmails = document.forms["add_project"]["projectreviewer_emails"].value;
        if (projectReviewerEmails == '') {
            // no no no no no
            return !valid;
        } else {
            // yeah yeah yeah yeah yeah
            return valid;
    </script>
    <cfform name="add_project" method="post" action="test.cfm?view=admin-add-process&entity=project" enctype="multipart/form-data" onsubmit="return checkReq();">
    <cfinput type="file" name="projectreviewer_emails" >
    <cfinput type="submit" name="sbmt" value="Submit">
    </cfform>

Maybe you are looking for

  • ITunes 10.2.2 Home sharing

    Hi!  I am using iTunes on my PC runing Windows Vista.  I am trying to use home sharing.  The other PCs can see and share my library easily but I cannot see or share either of the other libraries.  I have noticed that my iTunes does not have the "Look

  • Problem:obtaing file name using Dynamic configuration of file adapter

    hi all I am using Dynamic configuration for getting file name. I am getting Dynamic configuration in SXMB_MONI containg file name, but payload is empty unlike file i am sending.

  • Flickering Image update (only one Image drawn on Component), 10+ Duke Dolla

    I've made an RBGFilter for Images and Combined it with a Thread to make an Image fade from Color to Grayscale. I use it together with an home made JComponent. It works, but the Image flickers. I've tried longer sleep periods (I thougt that maybe the

  • Lightroom 2.7 issue importing CR2 files

    I have been using Lightroom 2.7 with my Canon G10 raw images successfully for several years, but I just had the G10 replaced with a G12 by Canon. When I downloaded my photos the first time, and tried to import them, I get errors tell me they failed t

  • Memory leak in Safari WebFeedParser

    Lately I've noticed that every so often a process com.apple.Safari.WebFeedParser is taking up more memory than it should be. Often times Has anyone seen this problem or know the cause of it?