1

コードをもっと正確にしたいのですが、次のコードスニペットをより適切に書くことを提案してくれる人はいますか?

<script>

var frmvalidator  = new Validator("SubscriptionForm");
 frmvalidator.EnableOnPageErrorDisplaySingleBox();
 frmvalidator.EnableMsgsTogether();

  frmvalidator.addValidation("usernameReg","req","Please enter your Username");
  frmvalidator.addValidation("usernameReg","maxlen=20", "Max length for Username is 20");
  frmvalidator.addValidation("usernameReg","alpha_s","Username can contain alphabetic chars only");

  frmvalidator.addValidation("usernameReg","req","Please enter your Username");
  frmvalidator.addValidation("usernameReg","maxlen=20", "Max length for Username is 20");
  frmvalidator.addValidation("usernameReg","alpha_s","Username can contain alphabetic chars only");
  frmvalidator.addValidation("fname","req","Please enter your First Name");
  frmvalidator.addValidation("fname","maxlen=20",   "Max length for FirstName is 20");
  frmvalidator.addValidation("fname","alpha_s","Name can contain alphabetic chars only");


  frmvalidator.addValidation("lname","req","Please enter your Last Name");
  frmvalidator.addValidation("lname","maxlen=20","For LastName, Max length is 20");

  frmvalidator.addValidation("email","maxlen=50");
  frmvalidator.addValidation("email","req");
  frmvalidator.addValidation("email","email");

</script>
4

1 に答える 1

0

@ニダ・ハフィーズ

次のプロジェクトで jquery の使用を開始する場合、これは大いに役立ちます: http://www.w3schools.com/jquery/default.asp

また、jQuery からの優れたフォーム バリデーターもあります。

http://docs.jquery.com/Plugins/Validation

于 2012-10-22T11:21:37.033 に答える