html部分
<form id="formbox" action="/a.php" method="post">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td align="left"><input type="text" class="abilityContact-left-input" name="contacts" placeholder="* Name"></td>
<td align="center"><input type="text" class="abilityContact-left-input" name="mobile" placeholder="Phone"></td>
<td align="right"><input type="text" id="email" class="abilityContact-left-input" name="email" placeholder="* Email" onchange="checkEmail(this.value)"></td>
</tr>
<tr>
<td colspan="3">
<textarea class="contactUsFont-textarea" id="content" placeholder="* Message" name="content" onchange="checkNum(this.value)"></textarea>
</td>
</tr>
<input type="hidden" name="company" value="Google Ads source">
<tr>
<td colspan="3">
<input type="submit" class="abilityContact-left-button" name="submit" id="submit" value="Send Message">
</td>
</tr>
</tbody>
</table>
</form>
js部分
<script>
function checkEmail(str){
var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/
if(!re.test(str)){
alert("Please enter the correct mailbox format");
return false;
}else{
return true;
}
}
function checkNum(str){
if(str.length<50){
alert("Please enter more words so that we can better understand your needs");
return false;
}else{
if(str.indexOf(' porn') != '-1') {
alert("Please enter the requirements related to the website. We don't accept advertisements");
return false;
}else{
return true;
}
}
}
$("#submit").click(function(){
var email=$("#email").val();
if(checkEmail(email)){
var content=$("#content").val();
// console.log(checkNum(content));
if(checkNum(content)){
return true;
}else{
return false;
}
}else{
return false;
}
});
</script>
评论 (0)