使用jquery进行简单的表单验证

时间:2010-11-09 15:40:55

标签: jquery-plugins validation jquery-validate

我在HTML中有非常简单的基本形式,我想使用jquery来验证表单。

我尝试使用bassistance.de验证插件但无法正常工作

<table cellspacing="2" cellpadding="2" border="0">
<tr>
  <td align="right">First Name</td>
  <td><input type="text" name="FirstName" class=" text hasCorners"></td>
</tr>
<tr>
  <td align="right">Last Name</td>
  <td><input type="text" name="LastName" class=" text hasCorners"></></td>
</tr>
<tr>
  <td align="right">EMail</td>
  <td><input type="text" name="Email" class=" text hasCorners"></></td>
</tr>
<tr>
  <td align="right">Phone</td>
  <td><input type="text" name="Phone" class=" text hasCorners"></></td>
</tr>
<tr>
  <td align="right">Address</td>
  <td><textarea cols="20" rows="5" name="Address" class=" text hasCorners"></></textarea></td>
</tr>
<tr>
  <td align="right">Country</td>
  <td>
  <SELECT name="Country" class=" text hasCorners"></>
    <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>

2 个答案:

答案 0 :(得分:-1)

我已经使用了JQuery Yab plugin一段时间,看看,这很好。

答案 1 :(得分:-1)

/**
 * @Route("/import")
 */
class ImportController extends AbstractController
{
    /**
     * @Route("/import", name="import_import", methods={"POST"})
     */
    public function import(Request $request): Response
    {
        $em = $this->getDoctrine()->getManager();

        $file = $request->files->get('file');
        $filename = $file->getRealPath();

    }
}