JSP page:

        <div id="ADDBUTTON" style="vertical-align: bottom;margin-left: 10px;display: none;"> <label style="text-align: center;"                class="titleblue_s4" >Add Part Description</label><br> <div class="Table"> <div class="Row"> <div class="Cell"><label class="graylabel2">Enter Part:</label><font color="red">*</font></div> <div class="Cell"><s:textfield cssClass="text" name="partEntered" id="partEntered" value="%{partEntered}" theme="simple" size="50" onkeydown="return validatetext(event);" onkeypress=" return validatetext(event);"  /> </div></div><div class="Row"> <div class="Cell"><label class="graylabel">Part Description:</label></div> <div class="Cell"> <s:textfield cssClass="text"  name="addpartdescrp" id="addpartdescrp" value="%{addpartdescrp}" theme="simple" size="50" maxlength="200" onkeydown="return validatetext(event);" onkeypress=" return validatetext(event);"/> </div> </div> <br> <div class="Row"> <div class="Cell"></div><div class="Cell"><input   type="button" id="addbutton" value="Submit"  onclick ="Acttt(this.value);"  /></div></div> </div> </div>

 function Acttt(str)

 //var EmptyPart=document.getElementById("partEntered").value;
 var EmptyPart1=document.getElementById("partEntered");
 var EmptyPart=EmptyPart1.value;


         alert ('Empty value is not allowedd');
           return false;

if(typeof EmptyPart == null || typeof EmptyPart ==="")
 //if(EmptyPart == null || EmptyPart ==="")
   alert('Please enter Part value');
   return false;

 var ddlArray= new Array();
var ddl = document.getElementById('listparts');
for (i = 0; i < ddl.options.length; i++) 
 ddlArray[i] = ddl .options[i].value;

//if(ddlArray[i] == EmptyPart)
   if(ddlArray[i] == EmptyPart.trim())

   alert('Duplicate part Entered please enter Unique Part');
   return false;


When I run into those things I'm off to caniuse.com to check out if it should or should not work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.