Jump to content

making Contact_Name a required field


Chrisj

Recommended Posts

I have this Form that works successfully (I know it's not state-of-the-art).
I simply want to add code to make Contact Name field mandatory.

I'm not sure if I should post all the code. Can you help me? thanks
 

<script type="text/javascript">
function checkemail(){
var str=document.myform.email_address.value;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if (filter.test(str))
testresults=true;
else {
alert("Please input a valid email address!");
return false;
}
if(document.myform.agree.checked!=1) {
alert("Please check the box to agree to the Terms.");
return false;
}
if(document.myform.ans.value.toLowerCase()!="white") {
alert("Please answer security question correctly: Black or White?");
return false;
}
return true;
}
</script>

 


 

Link to comment
Share on other sites

You need to add the code to your javascript.

 

If you don't know how to write javascript, you need to either learn or hire someone to do it.

If you make an effort, we can help you debug it. But you haven't written any code for this problem.

Link to comment
Share on other sites

Thanks for your reply. I'm learning all the time.

I believe I should add this code, but I don't know where it should go, and what else I need.

 

var username = document.myform.contact_name.value;
if (/^[a-z]+([ \'\-][a-z]+)*$/gi.test(username)) {
Link to comment
Share on other sites

That's a lot more complex than your original requirement. Making a field required is not the same as validating the value within in. A contact name also sounds to me a different thing than a username. *shrug* If you can't explain what you want it's not surprising you can't get it done.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.