Results 1 to 2 of 2

Thread: Making Contact_Name a mandatory Form field

  1. #1
    Join Date
    Feb 2005

    Making Contact_Name a mandatory Form field

    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. Can you help me?

    <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))
    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;

  2. #2
    Join Date
    Dec 2012
    NSW Australia
    document.myform.contact_name.value === "";
    return false;

    which is really useless.. because I could just put a *x* into the field and it would pass.

    You need to explain a bit more about mandatory other than being empty....

    do a little bit of homework on form validation...

    Have you tried the HTML input property *required*?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center