1

在我的 magento 应用程序中有一个像 customer 这样的模块。

此模块中的注册工作正常。

我想对注册表单进行验证。

我的模块中有其他字段。

我怎样才能做到这一点?

目前只有 firstnmae、lastname、email 验证工作,其他人无效。

我怎样才能做到这一点?

这是我的注册表单代码:

<form action="<?php echo Mage::getUrl('professional_registration/index/createpost') ?>"  method="post" id="form-validate" enctype="multipart/form-data">
        <ul class="form-list">
            <li>
                <label>First Name:<span>*</span></label>
                <input type="text" name="firstname" id="firstname" value="" title="UserFirstname" class="input-text">
            </li>
            <li>
                <label>Last name:<span>*</span></label>
                <input type="text" name="lastname" id="lastname" value="" title="UserLastname" class="input-text">
            </li>
            <li>
                <label>Credential/Degree (If applicable):<span>*</span></label>
                <input type="text" name="credentialdegree" id="credentialdegree" value="" title="Credential" class="required-entry">
            </li>
            <li>
                <label for="name">Company name:</label>
                <input type="text" name="company" id="company" value="" title="Company" class="input-text">
            </li>
             <li>
                <label for="name" class="required">Address:<span>*</span></label>
                <textarea name="address" id="address"></textarea>
            </li>
            <li>
                <label>Phone:<span>*</span></label>
                 <input type="text" name="telephone" id="telephone" value="" title="Telephone" class="input-text">
                <div class="clear"></div>
            </li>
            <li>
                <label>City:<span>*</span></label>
                <input type="text" name="city" id="city" value="" title="City" class="input-text">
           </li>  
               <li> 
               <label>State:<span>*</span></label>
                <select size="1" id="state" name="state" class="shipping_state float_lft">
                    <option selected="" value="">Select a State</option>
                    <option value="AK">Alaska</option>
                    <option value="AL">Alabama</option>
                    <option value="AZ">Arizona</option>
                    <option value="AR">Arkansas</option>
                    <option value="CA">California</option>
                    <option value="CO">Colorado</option>
                    <option value="CT">Connecticut</option>
                    <option value="DC">District of Columbia</option>
                    <option value="DE">Delaware</option>
                    <option value="FL">Florida</option>
                    <option value="GA">Georgia</option>
                    <option value="HI">Hawaii</option>
                    <option value="ID">Idaho</option>
                    <option value="IL">Illinois</option>
                    <option value="IN">Indiana</option>
                    <option value="IA">Iowa</option>
                    <option value="KS">Kansas</option>
                    <option value="KY">Kentucky</option>
                    <option value="LA">Louisiana</option>
                    <option value="ME">Maine</option>
                    <option value="MD">Maryland</option>
                    <option value="MA">Massachusetts</option>
                    <option value="MI">Michigan</option>
                    <option value="MN">Minnesota</option>
                    <option value="MS">Mississippi</option>
                    <option value="MO">Missouri</option>
                    <option value="MT">Montana</option>
                    <option value="NE">Nebraska</option>
                    <option value="NV">Nevada</option>
                    <option value="NH">New Hampshire</option>
                    <option value="NJ">New Jersey</option>
                    <option value="NM">New Mexico</option>
                    <option value="NY">New York</option>
                    <option value="NC">North Carolina</option>
                    <option value="ND">North Dakota</option>
                    <option value="OH">Ohio</option>
                    <option value="OK">Oklahoma</option>
                    <option value="OR">Oregon</option>
                    <option value="PA">Pennsylvania</option>
                    <option value="PR">Puerto Rico </option>
                    <option value="RI">Rhode Island</option>
                    <option value="SC">South Carolina</option>
                    <option value="SD">South Dakota</option>
                    <option value="TN">Tennessee</option>
                    <option value="TX">Texas</option>
                    <option value="UT">Utah</option>
                    <option value="VT">Vermont</option>
                    <option value="VA">Virginia</option>
                    <option value="WA">Washington</option>
                    <option value="WV">West Virginia</option>
                    <option value="WI">Wisconsin</option>
                    <option value="WY">Wyoming</option></select>
                </select>
             </li>
             <li>
                 <label>Postal Code:<span>*</span></label>
                 <input type="text" name="postcode" id="postcode" value="" title="Zip/Postal Code" class="input-text">
                 <div class="clear"></div>
             </li>    
              <li>
                 <label>Email:<span>*</span></label>
                 <input type="text" name="email" id="email" value="" title="Email" class="input-text">
            </li>
            <li>
                 <label for="email" class="required">Confirm Email:<span>*</span></label>
                 <input type="text" name="confirmemail" id="confirmemail" value="" title="Confirmemail" class="input-text">
            </li>            
            </ul>
                <p class="margin-top-3 margin-bottom-2 defult">
                   If you have proof of qualification for wholesale pricing (e.g. resale certificate, license) available in PDF, JPG, or BMP format, you can upload it here.
                </p>
                <div class="browse_div">
                    <div id="FileUpload" class="margin-top-1 float_lft">
                    <input type="file" size="24" id="BrowserHidden" onchange="getElementById('FileField').value = getElementById('BrowserHidden').value;"  />
                    <div id="BrowserVisible">
                    <input type="text" id="FileField" class="font_size" />
                    </div>
                    </div>
                </div>                

             <div class="clear"></div>
            <br clear="all" />
            <ul style="margin-top:5px">
            <li>
            <label>Please enter any additional information or questions here:</label>
            <div>
              <textarea name="additionalinfo" id="additionalinfo" value="" title="Additional Information"></textarea>
            </div>
            </li>
            </ul>

            <div class="submit_div">
            <input type="hidden" readonly="readonly" id="password" class="input-text " title="Password" value="123456" name="password">
            <input type="hidden" readonly="readonly"  id="confirmation" class="input-text " title="Confirmation" value="123456" name="confirmation">
            <input type="hidden" readonly="readonly" id="usertype" class="input-text " title="usertype" value="0" name="usertype">
            <input type="hidden" readonly="readonly" id="group_id" class="input-text " title="group_id" value="5" name="group_id">
            <input type="submit" class="submit margin-top-2" value="Submit" id="send">
            </div>
        </form>

更新:

我在脚本中添加了这段代码:

//<![CDATA[
    var contactForm = new VarienForm('form-validate', true);
//]]>

然后给出验证:

<li>
                <label>Credential/Degree (If applicable):<span>*</span></label>
                <input type="text" name="credentialdegree" id="credentialdegree" value="" title="Credential" class="required-entry">
            </li>

但没有效果,它只显示:

在此处输入图像描述

4

0 回答 0