This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Strip Dashes from Form Entry and Enter into MySQL?


  1. pakora
    Member

    I have a form where there is a field for Part Number.

    Some part numbers have dashes and slashes ( - , / )

    I want the part numbers to be saved in Mysql without any dashes or slashes.

    I cant figure this out. Thank you.

    Posted 16 years ago #
  2. yuniar

    Sorry, MachForm doesn't have any option to filter dashes or slashes.


    MachForm Founder

    Posted 16 years ago #
  3. pakora
    Member

    Thank you for your reply. Is there a workaround within the php code that I could program this to happen? Could you direct me to the proper file? Thank you.

    Posted 16 years ago #
  4. yuniar

    Ok, let say you have a form with id = 7 and your part number field is having id = 'element_3' (view the HTML source of your form to see this).

    Edit your includes/post-functions.php file, search around line 118 and you'll find this code:

    $element_type = $element_info[$element_id]['type'];


    Right under that code, insert this code:

    if($form_id == 7 && $element_name == 'element_3'){
    	$element_data = str_replace(array("-","/"),"",$element_data);
    }


    That would do it. Don't forget to adjust the code above with your own form id and element id.


    MachForm Founder

    Posted 16 years ago #

RSS feed for this topic

Reply