www.webdeveloper.com
Results 1 to 8 of 8

Thread: About form control

  1. #1
    Join Date
    Oct 2012
    Location
    istanbul
    Posts
    64

    About form control

    Hello,

    Could you help, please?

    My javascript isn't running regularly. Can you write with jQuery language?

    The rule are like in image below.
    add_task.png

    Thank you in advance
    Best Regards

  2. #2
    Join Date
    Jul 2013
    Posts
    66
    This isn't a free coding service. If you're completely disinterested in learning, go pay someone to do your job for you. If you want to learn something, then start with showing your attempts, even if they're not working right.

  3. #3
    Join Date
    Oct 2012
    Location
    istanbul
    Posts
    64
    I am amateur and novice
    My JS code
    Would appreciate if you help
    Code:
    <script type="text/javascript">
    
    function Checkit(theform) {
        if(theform.task_name.value==true) {
            error = "Please enter a short name of the task";
        }
         var taskname = document.getElementById('task_name').value;
         if (taskname.length > 20){
         error+="Please do not exceed 20 characters\n";
         }
    
        if(theform.week.value=="-1" && theform.day.value=="-1" && theform.hour.value=="-1" && theform.minute.value=="-1") {
            error += "Please select a time when the times \n";
        }
    
         var filename = document.getElementById('file_name').value;
         if (filename.length < 10){
         error+="Enter file name of running local file or full URL\n";
         }
                
        if(error) {
            alert('**These fields are required:**\n\n' + error);
            error = "";
            return false;
        } else {
            return true;
        }
    }
    
    </script>
    Thanks

  4. #4
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,653
    Adem, jQuery is not a language, it is just a very good and well known javascript framework. And it would be better to provide the full page code with your script instead of pictures. You know, some people do test their scripts before posting here and they need the proper HTML for that purpose

  5. #5
    Join Date
    Oct 2012
    Location
    istanbul
    Posts
    64
    Thank you for information.

    My script changed. I can't week area.

    I want to do the following rule:
    If it has selected only star (*) or (-1), you can submit. Because week has disabled.

    If it has selected day or days, week will enable, so you can't select (*) at the same time. If you select both of them and submit, javascript must alert. I want to do this but I can't. Can you help me?


    PHP Code:
    <script type="text/javascript">
    function 
    Checkit(theform) {
         var 
    gorevadi document.getElementById('gorev_adi').value;

        if (
    gorevadi.length 1){
         
    error ='-Please enter a short name of the task\n\n';   
        }

         if (
    gorevadi.length 20){
         
    error+="-Please do not exceed 20 characters\n\n";
         }               

          if(
    theform.haftanin_gunu.value=="") {
             
    error+="-If you want to use days of week, select day(s).\n-If you don't want to use days of week, select (*) and disable it.\n\n";
          }

    HERE CONTROL OF WEEK


         
    var dosyaadi document.getElementById('dosya_adi').value;
         if (
    dosyaadi.length 10){
         
    error+="-Please enter file name of running local file or full URL\n\n";
         }
                
        if(
    error) {
            
    alert('**THESE FIELDS ARE REQUIRED:**\n\n' error);
            
    error "";
            return 
    false;
        } else {
            return 
    true;
        }
    }
    </script> 
    PHP Code:
    <form method="POST" onsubmit="return Checkit(this);">
      <
    select size="8" name="haftanin_gunu[]" id="haftanin_gunu" multiple>  
            <
    option value="-1" selected="selected">*</option>
            <
    option value="0">Sunday</option>
            <
    option value="1">Monday</option>
            <
    option value="2">Tuesday</option>
            <
    option value="3">Wednesday</option>
            <
    option value="4">Thursday</option>
            <
    option value="5">Friday</option>
            <
    option value="6">Saturday</option>        
      </
    select>
      <
    p><input type="submit" value="Submit" name="B1">
      <
    input type="reset" value="Reset" name="B2"></p>
    </
    form
    TRUE http://awesomescreenshot.com/0561ox1e88

    TRUE http://awesomescreenshot.com/01e1ox1g4b

    FALSE http://awesomescreenshot.com/0de1ox1s9c


    Thanks in advance
    Last edited by Adem; 09-08-2013 at 05:24 PM.

  6. #6
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,653
    try this

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Multiple</title>
    <script type="text/javascript">
    function week_chck(obj){
    var val=[];
    for(var i=0;i<obj.options.length;i++){
    if(obj.options[i].selected===true){val.push(obj.options[i].value);}
    }
    if(val.length>1 && val[0]=='-1'){
    alert('You can not select "*" and anything else at the same time!');
    for(var k=1;k<obj.options.length;k++){obj.options[k].selected=false;}
    week_chck(obj);
    }
    }
    
    window.onload=function(){
    document.getElementById('haftanin_gunu').onchange=function(){week_chck(this);}
    }
    </script> 
    </head>
    <body>
    <form method="post" onsubmit="return Checkit(this);">
    <select size="8" name="haftanin_gunu[]" id="haftanin_gunu" multiple>  
    <option value="-1" selected="selected">*</option>
    <option value="0">Sunday</option>
    <option value="1">Monday</option>
    <option value="2">Tuesday</option>
    <option value="3">Wednesday</option>
    <option value="4">Thursday</option>
    <option value="5">Friday</option>
    <option value="6">Saturday</option>        
    </select>
    <p><input type="submit" value="Submit" name="B1">
    <input type="reset" value="Reset" name="B2"></p>
    </form>
    </body>
    </html>

  7. #7
    Join Date
    Oct 2012
    Location
    istanbul
    Posts
    64
    Quote Originally Posted by Padonak View Post
    try this

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Multiple</title>
    <script type="text/javascript">
    function week_chck(obj){
    var val=[];
    for(var i=0;i<obj.options.length;i++){
    if(obj.options[i].selected===true){val.push(obj.options[i].value);}
    }
    if(val.length>1 && val[0]=='-1'){
    alert('You can not select "*" and anything else at the same time!');
    for(var k=1;k<obj.options.length;k++){obj.options[k].selected=false;}
    week_chck(obj);
    }
    }
    
    window.onload=function(){
    document.getElementById('haftanin_gunu').onchange=function(){week_chck(this);}
    }
    </script> 
    </head>
    <body>
    <form method="post" onsubmit="return Checkit(this);">
    <select size="8" name="haftanin_gunu[]" id="haftanin_gunu" multiple>  
    <option value="-1" selected="selected">*</option>
    <option value="0">Sunday</option>
    <option value="1">Monday</option>
    <option value="2">Tuesday</option>
    <option value="3">Wednesday</option>
    <option value="4">Thursday</option>
    <option value="5">Friday</option>
    <option value="6">Saturday</option>        
    </select>
    <p><input type="submit" value="Submit" name="B1">
    <input type="reset" value="Reset" name="B2"></p>
    </form>
    </body>
    </html>
    Thank you very very very very very very very much, god bless your hands, excellent
    For this project: http://www.zamanlayici.antenfiyati.com
    Last edited by Adem; 09-10-2013 at 06:13 PM.

  8. #8
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,653
    you're welcome ))

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



Recent Articles