Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7610925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:32:13+00:00 2026-05-31T01:32:13+00:00

I need to validate the following form. Some fields are just required, however the

  • 0

I need to validate the following form. Some fields are just required, however the email field needs to include email validation. I have tried the following code:

Note: If I take out the ‘rules’ part, the validation works on all required fields however I need it to first check there is a value frmUser-email input (required) and then if there is a value in there, do the email validation.

<script type="text/javascript">
$(document).ready(function(){
    $("#adduser").validate({

        rules: {
            frmUser-email: {
                required: true,
                email: true
            }
        },
        errorClass: "my-error-class",
           validClass: "my-valid-class",
           groups: {
              required1: "frmUser-username frmUser-password frmUser-secretword frmUser-secretwordprompt frmUser-usertype"
         },
           errorPlacement: function(error, element) {
            error.appendTo('#errorlabel' )
        }

    });
});

<form id="adduser" name="adduser" method="post" action="?vars=<?php echo URLEncryptEncode('module=user&call=add-process',$urlp);?>">
<table border="0" cellspacing="0" cellpadding="0" class="forminput">
  <tr>
    <td>User Login Name:</td>
    <td><input name="frmUser-username" type="text" size="25" class="required"/></td>
  </tr>
  <tr>
    <td>Password:</td>
    <td><input name="frmUser-password" type="text" size="25" class="required"/></td>
  </tr>
  <tr>
    <td>Secret Word:</td>
    <td><input name="frmUser-secretword" type="text" size="25" class="required"/></td>
  </tr>
   <tr>
    <td>Secret Word Prompt:</td>
    <td><input name="frmUser-secretwordprompt" type="text" size="25" class="required"/></td>
  </tr>
  <tr>
    <td>Telephone:</td>
    <td><input name="frmUser-telephone" type="text" size="15"/></td>
  </tr>
  <tr>
    <td>E-Mail:</td>
    <td><input id="frmUser-email" name="frmUser-email" type="text" size="30"/></td>
  </tr>
  <tr>
    <td></td>
    <td colspan="2"><input type="submit" value="ADD NEW USER" class="button" /></td>
  </tr>
  <tr>
      <td></td>
    <td><label class="errorlabel" id="errorlabel"></label></td>
   </tr>
</table>
</form>

Hopefully someone can help out.. Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:32:14+00:00Added an answer on May 31, 2026 at 1:32 am

    First off, you can just specify both classes in your input:

    <input id="frmUser-email" name="frmUser-email" type="text" class="required email" size="30"/>
    

    But if you are set on using the rules object, you just need to quote fromUser-email because the - in the middle makes it invalid. So leave everything else the same, but do this for your rules object:

     rules: {
            'frmUser-email': {
                required: true,
                email: true
            }
        }  
    

    Do one or the other and you should be fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form in which some of the fields need to be validated
I have a situation that if my form doesn't validate I need it to
I need to validate phone number in PHP. I have made following regex, but
I have a registration form which I need to validate before submit. The form
I'm trying to use jQuery validation plugin to validate a few form fields by
I have the following problem: I need to validate data in a controller, which
I need to do a javascript form validation. I would like to validate each
I need to validate a date/time field on a webpage but want it to
I need to validate the email address of my users. Unfortunately, making a validator
I need to validate two user input fields against each other in seam. Field1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.