Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    Rendere un campo input non obbligatorio

    Ciao a tutti, spero mi scusiate se vi chiedo una cosa forse per voi semplice ma gradirei se mi deste una mano...
    ho un file in php dove c'è del codice js e php nel quale un campo (telefono) risulta obbligatorio e vorrei che non lo fosse...

    mi potreste indicare cosa cambiare?

    scusate il disturbo...spero mi possaite dare una mano...

    codice:

    -----------------------------------------------------

    <?php

    /**

    * $Id: default.php 10967 2008-09-26 00:01:51Z ian $

    */

    defined( '_JEXEC' ) or die( 'Restricted access' );



    $doc =& JFactory::getDocument();

    $doc->addStyleSheet( "components/com_ipricecalc/views/category/tmpl/freeprice.css" );



    ?>





    <script language="javascript" type="text/javascript">



    function form_hasValue(object, obj_type, optional_1, optional_2, optional_3) {

    switch (obj_type) {

    case "TEXT":

    if (object.value.length < 5) {return false;}

    return true;

    case "PASSWORD":

    if (object.value.length == 0) {return false;}

    return true;

    case "EMAIL":

    if (object.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {return false;}

    return true;

    case "TEXTAREA":

    if (object.value.length < 1) {return false;}

    return true;

    case "SELECT":

    for (i=0; i < object.length; i++) {

    if (object.options[i].selected && object.options[object.selectedIndex].value != 0 ) {return true;}

    }

    return false;

    case "SINGLE_VALUE_RADIO":

    if (object.checked) {return true;}

    return false;

    case "SINGLE_VALUE_CHECKBOX":

    if (object.checked) {return true;}

    return false;

    case "RADIO":

    for (i=0; i < object.length; i++) {

    if (object[i].checked) {return true;}

    }

    return false;

    case "CHECKBOX":

    for (i=0; i < object.length; i++) {

    if (object[i].checked) {return true;}

    }

    return false;

    case "EURO_DATE":

    var firstSlash, secondSlash, month, day, year;

    if (object.value.search(/^\d{1,2}\/\d{1,2}\/\d{1,4}$/) == -1) {return false;}

    var firstSlash = object.value.indexOf('/');

    var month = object.value.substring(0, firstSlash);

    if (!((month >= 1) && (month <= 12))) {return false;}

    var secondSlash = object.value.indexOf('/', firstSlash + 1);

    var year = object.value.substring(secondSlash+1,object.value. length);

    if (!((year >= 1900) && (year <= 2100))) {return false;}

    var day = object.value.substring(firstSlash+1, secondSlash);

    if (!form_checkDayOfMonth(year,month,day)) {return false;}

    return true;

    case "CREDIT_DATE":

    var firstSlash, month, year;

    if (object.value.length == 0) {return false;}

    if (object.value.search(/^\d{1,2}\/\d{1,2}$/) == -1) {return false;}

    var firstSlash = object.value.indexOf('/');

    var month = object.value.substring(0, firstSlash);

    if (!((month >= 1) && (month <= 12))) {return false;}

    var year = object.value.substring(firstSlash+1,object.value.l ength);

    if (!((year >= 0) && (year <= 99))) {return false;}

    return true;

    case "INTEGER":

    if (object.value.length == 0) {return false;}

    else {

    if (object.value.search(/^\d+$/) == -1) {return false;}

    }

    return true;

    case "NUMBER":

    if (object.value.search(/^\-?\+?\d*\.?\d+$/) == -1) {return false;}

    return true;

    case "PHONE_NUMBER":

    if (object.value.search(/^[ \+\-\(\)\d]{5,}$/) == -1) {return false;}

    return true;

    case "CREDITCARDNUMBER":

    if (object.value.search(/^[\d| ]+$/) == -1) {return false;}

    return true;

    case "SELECTNOTZERO":

    for (i=0; i < object.length; i++) {

    if (object.options[i].selected) {

    if(object.options[i].value != 0) {return true;}

    }

    }

    return false;

    case "NUMDATE":

    if (object.value.search(/^\-?\+?\d*\.?\d+$/) == -1) {return false;}

    if (object.value.length != 6) {return false;}

    if(object.value.substring(0,2) > 31) {return false;}

    if(object.value.substring(2,4) > 12) {return false;}

    return true;

    case "NUMTIME":

    if (object.value.search(/^\-?\+?\d*\.?\d+$/) == -1) {return false;}

    if (object.value.length != 4) {return false;}

    if(object.value.substring(0,2) > 24) {return false;}

    if(object.value.substring(2,4) > 60) {return false;}

    return true;

    }

    }



    function checkHaveValues (checkList) {

    loopLength = checkList.length / 3;

    for (x=0;x<loopLength;x++) {

    message = checkList[(x*3)];

    checkItem = checkList[(x*3)+1];

    type = checkList[(x*3)+2];

    if (!form_hasValue(checkItem,type)) {

    alert(message);

    if (checkItem.type == "TEXT" || checkItem.type == "PASSWORD") {

    checkItem.focus();

    }

    return false;

    }

    }

    return true;

    }



    function validate(formName) {

    if (!checkHaveValues(new Array(

    "<?php echo JText::_('Contact person needed');?>",formName.fio,"TEXT",

    "<?php echo JText::_('Phone number needed');?>",formName.phone,"TEXT",

    "<?php echo JText::_('Correct e-mail needed');?>",formName.email,"EMAIL")))

    {return false;}

    else {

    formName.submit();

    return true;

    }



    }



    function show_desc(iid) {

    if (iid.style.display == '') iid.style.display='none'; else iid.style.display='';

    };



    function check_event(){

    var sum_ = new Array();

    var price_list=new Array(), i_list=new Array(), i_box_list=new Array(); i_radio_list=new Array();

    <?php

    // echo ('var cnt_ = '.$this->catcount.'; ');

    $i = -1;

    $curcatnum = -1;

    $itemnum = -1;

    $curcat = '';

    foreach ($this->items as $item) {

    $i++;

    $itemnum++;

    if ($curcat != $item->category) {

    $curcatnum++;

    $itemnum = 0;

    $curcat = $item->category;

    echo ('price_list['.$curcatnum.'] = new Array(); i_list['.$curcatnum.'] = new Array(); i_box_list['.$curcatnum.'] = new Array(); i_radio_list['.$curcatnum.'] = new Array();');

    };

    echo (" price_list[".$curcatnum."][".$itemnum."] = ".$item->cost."; ");

    echo (" i_list[".$curcatnum."][".$itemnum."] = document.getElementById('i_".$i."'); ");

    echo (" i_box_list[".$curcatnum."][".$itemnum."] = document.getElementById('i_box_".$i."'); ");

    echo (" i_radio_list[".$curcatnum."][".$itemnum."] = document.getElementById('i_radio_".$i."'); ");

    }

    ?>

    var j;

    for (var i = 0; i < i_list.length; i++){

    sum_[i]=0;

    for (j = 0; j < i_list[i].length; j++){

    if(i_box_list[i][j].checked || i_list[i][j].value != '0' || i_radio_list[i][j].checked){

    if(i_list[i][j].style.visibility == 'hidden'){

    sum_[i] = sum_[i] + price_list[i][j];

    }else{

    sum_[i] = sum_[i] + price_list[i][j] * i_list[i][j].value;

    };

    };

    };

    };

    var SUM=0;

    for(i=0; i<i_list.length;i++) {

    SUM = SUM + sum_[i];

    document.getElementById('results_'+i).innerHTML = <?php echo JText::sprintf('Valujs','sum_[i].toFixed(2)')?>;

    }

    document.getElementById('results_bottom').innerHTM L = <?php echo JText::sprintf('Valujs','SUM.toFixed(2)')?>;

    };

    </script>



    <?php

    $introtext = $this->params->get('introtext','');

    $headertext = $this->params->get('headertext','');

    if ($headertext) { ?>

    <table class="contentpaneopen" style="text-align:center";><tr><td class="contentheading" width="100%"><?php echo $headertext;?></td></tr></table>


    <?php

    }



    if ($introtext) { ?>

    <table class="contentpaneopen"><tr><td valign="top"><?php echo $introtext;?></td></tr></table>

    <?php

    }

    ?>



    <form action="" name="calc_form" method="POST" onsubmit="return validate(this);">



    <?php

    $pparams = $mainframe->getPageParameters('com_ipricecalc');

    $use_tabs = $pparams->get('use_tabs');

    if ($use_tabs == 1)

    {

    $advtabs=$pparams->get('use_tabtmpl');

    switch ($advtabs)

    {

    case 'default':

    echo $this->loadTemplate('stdtabs');

    break;

    case 'advanced':

    echo $this->loadTemplate('advtabs');

    break;

    default:

    echo $this->loadTemplate('advtabs');

    $doc = & JFactory::getDocument();

    $doc->addStyleSheet( 'components/com_ipricecalc/js/css/'.$advtabs.'.css' );

    break;



    }



    }

    else

    {

    echo $this->loadTemplate('nonetabs');

    }



    ?>






    <center><input type="button" class="button" onclick="document.getElementById('order_dat').styl e.display=''; style.display='none'" value="<?php echo JText::_('Preorder');?>">

    </center>




    <div style="display: none;" id="order_dat" name="order_dat">



    <table cellSpacing=0 cellPadding=0 width="100%" border=0 align=center>

    <tr >

    <td colspan=4 class="tablzag2"><?php echo JText::_('Contact info');?></td>



    </tr>

    <tr><td colspan=4>

    <table cellpadding=0 cellspacing=0 width=100% border=0>

    <tr class="tablchet" >

    <td align=right class="tablchet"></td>

    <td colspan=3 class="tablchet"></td>

    </tr>

    <tr class="tablchet" >

    <td align=right width=200px class="tablchet"><?php echo JText::_('Contact person');?><span class="textwarn">*</span>:</td>

    <td colspan=3 class="tablchet"><input name="fio" maxlength="90" type=text value="<?php echo $this->username ;?>" class="form" ></td>

    </tr>

    <tr class="tablchet" >

    <td align=right width=200px class="tablchet"><?php echo JText::_('Company name');?></td>

    <td colspan=3 class="tablchet"><input name="firm" maxlength="90" type=text class="form" value=""></td>

    </tr>

    <tr class="tablchet" >

    <td align=right width=200px class="tablchet"><?php echo JText::_('PHONE NUMBER');?> </td>

    <td colspan=3 class="tablchet"><input name="phone" maxlength="60" type=text class="form" value="" ></td>

    </tr>

    <tr class="tablchet" >

    <td align=right width=200px class="tablchet" ><?php echo JText::_('E-Mail');?><span class="textwarn">*</span>:</td>

    <td colspan=3 class="tablchet" ><input name="email" type=text maxlength="60" class="form" value="<?php echo $this->useremail ;?>" ></td>

    </tr>

    <tr class="tablchet" >

    <td align=right width=200px class="tablchet"><?php echo JText::_('Comments');?></td>

    <td colspan=3 class="tablchet" ><textarea name="comments" cols="30" maxlength="500" rows=5 class="textarea" ></textarea></td>

    </tr>

    <tr class="tablchet" >

    <td align=right width=200px class="tablchet"><?php echo JText::_('Send copy');?></td>

    <td colspan=3 class="tablchet" ><input name="copyemail" type="checkbox" CHECKED ></textarea></td>

    </tr>

    <tr class="tablchet" >

    <td align=right colspan=4 class="tablchet"><span class="textwarn">*</span><?php echo JText::_('Mandatory');?></td>

    </tr>

    <tr class="tablchet" >

    <td align=right width=200px class="tablchet"></td>

    <td colspan=3 class="tablchet" ><input name="submit" type=submit class="button" value="<?php echo JText::_('Send order');?>"></td>

    </tr>

    </table>

    </td></tr>

    </table>

    </div>

    <input type="hidden" name="option" value="com_ipricecalc" /><input type="hidden" name="view" value="category" /><input type="hidden" name="task" value="submit" />

    <input type="hidden" name="countitems" value="<?php echo count($this->items)?>" />

    <?php echo JHTML::_( 'form.token' ); ?>

    </form>

    -----------------------------------------------------

    Grazie

  2. #2
    Utente di HTML.it L'avatar di bstefano79
    Registrato dal
    Feb 2004
    Messaggi
    2,520
    cambia
    if (object.value.search(/^[ \+\-\(\)\d]{5,}$/) == -1) {return false;}

    con
    if (object.value!='' && object.value.search(/^[ \+\-\(\)\d]{5,}$/) == -1) {return false;}

  3. #3
    Originariamente inviato da bstefano79
    cambia
    if (object.value.search(/^[ \+\-\(\)\d]{5,}$/) == -1) {return false;}

    con
    if (object.value!='' && object.value.search(/^[ \+\-\(\)\d]{5,}$/) == -1) {return false;}
    Grazieeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

    mitico...


  4. #4
    Originariamente inviato da bstefano79
    cambia
    if (object.value.search(/^[ \+\-\(\)\d]{5,}$/) == -1) {return false;}

    con
    if (object.value!='' && object.value.search(/^[ \+\-\(\)\d]{5,}$/) == -1) {return false;}
    ciao Stefano (o chi mi può aiutare), scusami ho notato che quando invio il form non da nessuna scritta di conferma dell'avvenuta spedizione...

    infatti una volta inviato il form ricarica la stessa pagina ma chi invia dovrebbe avere una indicazione del tipo : Grazie per aver invato la mail"

    dove potrei inserire queste info?

    grazie


  5. #5
    Utente di HTML.it L'avatar di bstefano79
    Registrato dal
    Feb 2004
    Messaggi
    2,520
    cerca nei file la funzione mail

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.