hi,

how to write javascript code to validate first 2 textboxes that are generated from databses without "id" "name".
eg:here everything comes from databse.

name:<input type="text" id="{id}" name="{id}" class="textbox"/> "+" this feilds are generated with + button from database

age:<input type="text" id="{id}" name="{id}" class="textbox"/>  this does not have "+"

here "toggle plus" create image botton that is "+" button that has onclick function to validate

when i click first 2 textboxes should be valiadted

here i need to validate wheather first feild is added that is name is entered then age should be entered compulsary before saving.

here is the xsl that i have created


hi,


<table cellpadding="0" cellspacing="1" border="0" class="appFixedTable">
                                          <col style="width:25%"/>
                                          <col style="width:15%"/>
                                          <col style="width:15%"/>
                                          <col style="width:15%"/>
                                          <col style="width:15%"/>
                                          <col style="width:15%"/>
                                          <tr class="resultsHeader">
                                            <td align="left" colspan="7">
                                              Attributes
                                            </td>
                                          </tr>
                                          <xsl:for-each select="//awi:DrbBundle[awi:Bundle = $vendorBundle]">
                                            <xsl:sort select="awi:Key"/>

                                            <xsl:variable name="internalId">
                                              <xsl:value-of select="awi:Key"/>
                                            </xsl:variable>

                                            <xsl:if test="//awi:ImplProgramValue[awi:ProgramId = $programId and awi:InternalId = $internalId]">
                                              <tr>
                                                <td colspan="7">
                                                  INTERNAL ID:
                                                  <xsl:value-of select="awi:Value"/>
                                                </td>
                                              </tr>
                                              <xsl:for-each select="//awi:ImplProgramValue[awi:ProgramId = $programId and awi:InternalId = $internalId]">
                                              <xsl:sort select="awi:Key"/>







//these are feilds generated from database that r not generated with button <xsl:variable name="isNotGridCell" select="not(starts-with(awi:Key, 'branded-web-hours-') or starts-with(awi:Key, 'ivr-800-') or starts-with(awi:Key, 'web-800-') or starts-with(awi:Key, 'web-hours-') or starts-with(awi:Key, 'ivr-hours-') )"/>





  <xsl:if test="$isNotGridCell">
// thses feilds have "+" button beside textboxes

 <xsl:variable name="useGrid" select="awi:Key = 'branded-web-hours' or awi:Key = 'ivr-800' or awi:Key = 'web-800' or awi:Key = 'web-hours' or awi:Key = 'ivr-hours'"/>
<xsl:variable name="useGrid1" select="awi:Key = 'APPID' "/>

 <xsl:variable name="programValueName" select="awi:Key"/>







                                                  <xsl:variable name="id">
                                                    <xsl:value-of select="$programId"/>-<xsl:value-of select="$internalId"/>-<xsl:value-of select="awi:Key"/>
                                                  </xsl:variable>

                                                  <xsl:variable name="defaultValue">
                                                    <xsl:choose>
                                                      <xsl:when test="exists(awi:Value)">
                                                        <xsl:value-of select="awi:Value"/>
                                                      </xsl:when>
                                                      <xsl:otherwise>
                                                        <xsl:value-of select="''"/>
                                                      </xsl:otherwise>
                                                    </xsl:choose>
                                                  </xsl:variable>

                           <tr>

                                                    <td align="left">

                                                      <xsl:value-of select="awi:Key"/>
                                                    </td>

                                                    <td align="left" colspan="6">

                             <xsl:choose>
                                                      <xsl:when test="awi:Key = ' BI REPORT'">

                                                      Region <input type="checkbox" id="region" name="region" size="40" />
                                                      Order Class <input type="checkbox" id="order" name="order" size="40" />

                                                      </xsl:when>

                                                      <xsl:otherwise>

              //here these are corresponding textboxes for feilds  ** <input type="text" id="{$id}" name="{$id}" size="40"  class="textbox" value="{$defaultValue}">
                                                        **
                                                        <xsl:if test="$useGrid1">
                                                          <xsl:attribute name="style">float:left;</xsl:attribute>
                                                        </xsl:if>
                                                       </input>
                                                       <xsl:if test="$useGrid1 ">
                                                      <a href="#" class="toggle-plus" onclick="return toggleGrid(this, '{$id}');"> </a>
                                                        </xsl:if>
                                                        </xsl:otherwise>



                                                    </xsl:choose>

                        </td>
                                                    </tr>



                        </table>
       any help is appreciated.



   regards 

use html5 pattern and required attribute in that case
eg:

   <input type="tel" pattern="\d\d\d\d-\d\d\d\d" required>
Be a part of the DaniWeb community

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