jquery表單驗證外掛程式實現表單驗證執行個體

來源:互聯網
上載者:User

php檔案

 代碼如下 複製代碼

<?php
extract($_REQUEST);
$data = include './data.txt';
if(isset($data[$username])) exit('please other username.');
$data[$username] = $username ;

file_put_contents('./data.txt',"<?php return ".var_export($data,TRUE)." ?>");
echo 'success';
?>

css

<link href="skin.css" rel="stylesheet" type="text/css" />
<style>
.errorTip{
 background-image:url(images/access_disallow.gif);
 background-repeat:no-repeat;
 padding-left:16px;
}

.errorInput{
 background-color:#FFCC33;
}

.validTip{
 background-image:url(images/access_allow.gif);
 background-repeat:no-repeat;
 background-position:left top ;
 padding:2px;
}
</style>

<div class="item">
 <div class="title">基本檢驗 不可為空</div>
<form id="myform1">
<input type="text" require="true" datatype="require" msg="此項不可為空" />
<br />
<input type="submit" value="提交" /><input type="button" class="showsource" value="源碼" />
</form>
<textarea class="source" showed="0"></textarea>
<script>
$('#myform1').checkForm();
</script>
</div>

<div class="item">
 <div class="title">基本檢驗 電子郵件</div>
<form id="myform2">
<input type="text" require="true" datatype="email" msg="電子郵件地址要合法" />
<br />
<input type="submit" value="提交" /><input type="button" class="showsource" value="源碼" />
</form>
<textarea class="source" showed="0"></textarea>
<script>
$('#myform2').checkForm();
</script>
</div>

<div class="item">
 <div class="title">基本檢驗 非必需項但非空時格式要正確</div>
<form id="myform3">
<input type="text" require="false" value="abc" datatype="email" msg="電子郵件格式錯誤" />
<br />
<input type="submit" value="提交" /><input type="button" class="showsource" value="源碼" />
</form>
<textarea class="source" showed="0"></textarea>
<script>
$('#myform3').checkForm();
</script>

下載地址:http://www.111cn.net/demo/jfom.zip

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.