HTML form submission with special characters - html

I am trying to submit a form field whose value is Transaction ID - sample . When the date gets submitted the value is Transaction ID ? sample
How do I get rid of the ?
I used HTML special codes for dash/long dash/short dash but still value gets submitted as ?
Please help

The only way to ensure that all input characters get sent correctly is to use UTF-8 character encoding for the form data. This happens automatically if the page containing the form is UTF-8 encoded (and declared to be that); otherwise, use the parameter accept-charset=utf-8 in the form data.
Naturally, you form handler must then be prepared to handling UTF-8 encoded data.

Related

How can I pass '#' as part of a parameter in html?

I have an html form that I desire to be pre-populated with variables that are passed as parameters within the URL. Basically imagine that I am typing this string directly into the browser.
When I pass a variable that contains '#' however, it is read as syntax different from the string and the full variable is not copied into the form.
Example: https://form.domain.com/formname??variable1=www.variabledomain.com/#/h7Y6F53/
When I enter this into my browser, variable1 pre-populates only with "www.variabledomain.com/". I'd like it to pre-populate with "www.variabledomain.com/#/h7Y6F53/".
What can I do differently?
Cheers

Saving values containing comma's in a HTML Multiple select

I have a HTML multiple select being used which caused no issue until a selection with a comma was entered. When saving / loading the values are split by ',' into a list. Therefore causing an issue
I have tried to find a way of possibly changing the character that is being used to split the values when the form is posted but came to a dead end.
Would be very grateful if someone has any insight into this.
Thanks in advance.
---Update with Code---
The control is created dynamically
Dim SelectName1 As New HtmlSelect
SelectName1.ID = "SelectName" & id
SelectName1.Name = "SelectName"
SelectName1.Multiple = True
and filled by looping though the values.
For Each value As String In Request.Form(idToFind).Split(",")
If Not IsDBNull(SelectName.Items.FindByValue(value)) Then....
I cannot add any more code than that, Apologies
After updating the question by add code, I think the available options are limited:
Create an extra Javascript method, that stores the selected values in a json object and store it into a hidden input field. I'm not an expert in asp.net, though I'm sure there exists a method to parse json objects from a string.
Create an extra javascript method, that concatinating all values to a String and store it into a hidden input field. With creation of a single string, you can define your own delimiter.
After that, add this extra Javascript mehod to the event onSubmit. Then submit the form and read the value from hidden input field.
P.S. In my eyes the second idea is more simple to create, than the first one. And maybe there are better ways.

Not saving to db if form input fields are empty?

I have created Wordpress custom fields through functions.php. My code works fine, and I've few input fields and some checkboxes.
Problem is when I save post, even if I don't put content inside my form, these rows are created in DB. I'd like to do some kind of php check and avoid creation of row in DB if field content is not saved.
I tried several ways, but in most cases it would result in incorrect behaviors of checkboxes for example.
Full code is here: http://pastebin.com/embed_js.php?i=Vvnseiep
I'd appreciate your help in this matter. I'm not very experienced.
Thanks!
Here Validation part comes into play. Why cant you use Javascript to validate your input in the client environment itself and then allowing it to hit the db.
Name all of the checkboxes the same(name="meta_box_check[]"). They must still have different ID's. When the form is posted you will be given an array of values that were checked in $_POST['meta_box_check']. You can then check if the array is empty. You can also save the checkbox data as JSON data. This isn't always good practice, but will only use one data row to save any and all checkbox values.
<?php
if(!empty($_POST['meta_box_check']))
{
//process your data and save it
update_post_meta($post_id, 'meta_features_checklist', json_encode($_POST['meta_box_check']));
}
?>
This is a basic example and make sure you do some data validating before saving.

Use of Quotes in Form Element values

I have created a Textarea control. The data entered in this control goes to a database when Submit is clicked. However, when the user types single quotes while entering value in this control and clicks Submit, data does not go to the database.
How can I allow users to enter special characters like this while entering data in the form?
When inserting data in a query, you have to escape them with mysql_real_escape_string() (if mysql database). This protects you from SQL Injections.
mysql_query("INSERT INTO table(col) VALUES('".mysql_real_escape_string($data)."')");
When showing data in form elements, you have to escape them like this with htmlspecialchars() function. This protects you from XSS.
<textarea><?php echo htmlspecialchars($data, ENT_QUOTES); ?></textarea>

Populate plugin not working correctly

Hi i'm trying to retrieve and populate a form. The following link with username Testing and password test123 .
The page is returning a correct JSON object (I tested it by putting on screen between paragraph tags) but the populate plugin is not populating. In firebug it show "no such element as" without displaying the element's name. The input field names are exactly the same is in the DB.
any ideas?
The problem is that your success callback gets passed a string argument, instead of the expected Object/Array, which causes the populate method to treat the whole input as a single unnamed value. This is caused by a typo in the options object passed to your $.ajax() call:
$.ajax({
// ...
datatype: 'json'
});
The option names are case sensitive and the correct spelling for the datatype attribute is dataType with a capital tee. By default, if the datatype option is missing/misspelled, jQuery will try to intelligently guess the datatype of the response and return the result as a formatted string (see the jQuery documentation). So just rename the datatype option to dataType and your fields get populated correctly.