#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    How to Make an existing field non-mandatory/optional


    Hi ,
    I have a City field that is currently mandatory and required to be filled out for the signup process. I want to make it into Non-Mandatory field and have it as a optional field. I tried removing the class="required" , but it does not work. Please help. I am enclosing the parts of code that deals with city here.
    ===
    <?
    include('include/define.php');
    include("include/function.php");
    if (isset($_REQUEST['mode']) && $_REQUEST['mode']=="add"){
    $city_id=trim($_REQUEST['city_id']);}
    $data['city_id']=$city_id;
    function showcity(e,d){
    ajaxpage('show_city.php?id='+e,d);
    } <tr>
    <td>City: <span class="style1">*</span></td>
    <td><div id="citydiv">
    <select name="city_id" id="city_id" class="required">
    <option value=""> Select City </option>
    </select>
    </div></td>
    </tr>

    ===
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    there are no mandatory or optional fields in HTML. So any error message you get about not having filled out the field comes from the code itself.

    If you cannot even submit the form, it's JavaScript. If you get the message after the submit, it's PHP.

    In any case, the code is not in the snippet you gave us.

    Comments on this post

    • phphelp20023 agrees
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0
    Jacques1, Thank you for the reply. The message comes AFTER I hit the Submit button. I don't want to paste my complete code here. Is there any way I can send you the code via email or any other means? I think it is a pretty simple fix, but I am not able to find the issue. Please help me in resolving this issue.
    Thx again,
    Gita
  6. #4
  7. Known to taste like chicken
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    In front of my computer
    Posts
    399
    Rep Power
    312
    Originally Posted by phphelp20023
    Jacques1, Thank you for the reply. The message comes AFTER I hit the Submit button. I don't want to paste my complete code here. Is there any way I can send you the code via email or any other means? I think it is a pretty simple fix, but I am not able to find the issue. Please help me in resolving this issue.
    Thx again,
    Gita
    Search your code for the error message you are getting, then change the code to not require that field. There will probably be something like

    PHP Code:
    if($blah == "") {
    // some kind of error message

    depending on how complex the code is, it should be pretty easy to change.
    "Take thy beak from out my heart, and take thy form from off my door" - Homer J Simpson / Edgar Allan Poe

    Looking for a project Idea?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0
    Originally Posted by sir_drinxalot
    Search your code for the error message you are getting, then change the code to not require that field. There will probably be something like

    PHP Code:
    if($blah == "") {
    // some kind of error message

    depending on how complex the code is, it should be pretty easy to change.
    ==============================================

    Hi Sir_drinxalot,

    Thank you for taking time to reply me on Christmas. I will check the complete code again for this point.

IMN logo majestic logo threadwatch logo seochat tools logo