Form validation

2019-09-09 15:01发布

Anyone who can help with uni assignment. I can't make my form to validate. I need to validate only two fields. Email and credit card number. But I suck in javascript. I was trying to make work simultaneously work two scripts. But I didn't succeed. Anyone who can help me? Any links? Maybe some of you know some good and working script? Thank you in advance. Really simple form, only for uni purposes. Form looks like this:

<form name="checkoutform1" action="" method="post">
<table>
<tr>
<td>Email:</td>
<td><input type="text" name="email" size="15" maxlenght="65" value=""/></td>
<tr>
<td>Card number:</td>
<td><input type="text" name="cardnumber" size="16" maxlenght="16" value="" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Purchase"/></td>
</tr>
</table>
</form>

2条回答
我命由我不由天
2楼-- · 2019-09-09 15:44

Javascript or JQuery is not in a position to validate a form. That is up to the server.

Javascript can only improve the users experience by having a very good stab at sending reasonable data to the server. It is still up to the server to accept/reject it.

Indeed the user is free to disable Javascript.

查看更多
手持菜刀,她持情操
3楼-- · 2019-09-09 15:49

Check out the jQuery Validation plugin. It has credit card and email validation, so you don't need to re-invent the wheel when it comes to basic validation.

查看更多
登录 后发表回答