Rails date field not removing date when updating - ruby-on-rails-3

I have a form with a text field for inputting a date:
<%= f.text_field :my_date %>
If I input a date into this field, click submit and then go back to the form again and remove the date value that I've just entered (with no validation applied) the form saves but the original date is still there. I can't get rid of it once I've entered and saved it.
Am I doing something wrong?

It was because it is a virtual attribute and needed to use "" if it thought it was nil

Related

Datetimepicker refuses to display date on page load

So, I am using the datetimepicker by eonasdan. Everything appears to work fine except one field.
The field in question clears the input box that the date is in. Why does it not stay there?
I have tried the options defaultDate and useCurrent, but nothing seems to make a difference.
Here a sceenshot of my form:

Trying to fill textbox value with today's date only on visual basics

I am trying to fill a textbox value with the current date and I do not want the user to be able to change the date. I want to use a textbox and not a datepicker. I would like the form to load with today's date already loaded in the textbox, which I will then use in my insert query.
I want the date format of yyyy-MM-dd to be in the textbox memberregisterationdate.text. I am not sure where on my form I should put the code either.
Really stuck on this and I can't seem to find it anywhere
Thanks in advance
You have to make it Enabled = False to disable it. You can load it in Form_Load:
memberregisterationdate.Text = Date.Today.ToString("yyyy-MM-dd")

How to generate adidional fields inside Yii form

I have:
Table "user"
id, username, password
Table "freedate"
id, user_id, start_date, end_date
Each user can have 1 or more (unlimited) number of "freedate" entries.
Now i have form with 2 text fields (username and password), and 2 date pickers (one for start date and another one for end date).
How can i enable user to inserd aditional datepicker pairs so they can enter as much of "freedate" entires as they need to?
I was wondering about insertind aditional button inside form, that would somehow create aditional fields when pressed, but u have no idea how to do it.
I don't need working example (even tho one would help ofc). What i need i suggestion from your own expirience if you had similar problem.
You can use javascript as noted above. Though that can get tricky to get the new fields associated with the datepicker.
You can also submit after each pair is entered. On returning back to form after save insert a new set of start/end date fields to the end of the form. This way they always have a freedate pair they can enter. (a bit slower overall)
You need javascript to generate these fields on the fly. Or a fixed amount of extra fields could be hidden and shown one by one using javascript as the user clicks the button. You would need to keep track of the number of fields being shown in a javascript var.
You need to write custom javascript in order to do that. It isn't hard, you would need to do something along these lines:
You need to create a button and, when that button gets clicked (onClick event or jquery click() function) you can add the html for your field (<input type=.... /> and so on to your form) and remember to use the correct name for these fields so that they get sent correctly when the user submits the form.

Make VB.Net DatePicker Required

I have a datepicker in a vb.net clickonce application. I need to make sure that in order to use the application that selecting a valid date is required. Ideally, I would be able to set the value of the datepicker to null and then programatically create Try Catch logic based on datepicker1.value still being null. Unfortunately, it will not allow me to assign a null or blank value to the datepicker. I cannot create my logic based on any real values of the datepicker because who's to say the value picked is not valid. I've tried setting the value to some outrageous date that no one would pick for the application like 1/1/1970, but then the datepicker opens up at 1/1/1970 and drops that date in as soon as it gains focus. I need a way to validate whether or not someone has selected a date, but am stuck and can't find any real help online. I am not looking to set the customformat = "", so please do not respond with that solution. I need the actual value to be blank or something I can run validation against to know that the user has in fact selected a date.
Set the ShowCheckBox property to true. That will make the control look like this...
When the user selects a date, it will check the checkbox. Then when you need the value...
If datePicker.Checked Then
'user has selected a value
Else
'user has NOT selected a value
End If
Can you use the ValueChanged event to set a flag to tell you they've clicked on a date?
UPDATE
You could also use the OnClick method to set a flag to verify the user actually clicked on the DateTimePicker.

classic asp - response.redirect and response.write problem

The problem if someone types into the search box a location it goes through to that location page but if they type in a location thats not found or they dont type anything in I need it to redirect back to the homepage (index.asp) and display "whoops we couldnt find that" in the search box (input field)
This is the vb
Case Else
response.redirect "index.asp?whoops=whoops we couldnt find that"
End Select
Then in the value of the input field I have
value="<% =whoops %>"
This doesnt work by the way, first is this the best way of doing it because id rather not have the error message in the url. This there away of posting the error as a variable and then calling it into the input field like,
<% =whoops %>
You don't need the error message in the url. Also, whoops won't be available to you as a variable just because it is in the url. You have to look for it in the Request.Querystring collection. What you'd want to do is something more like this on the homepage:
Dim whoops : whoops = ""
If Request.Querystring("whoops") Then
whoops = "whoops we couldnt find that"
End If
Then you could output <%=whoops %> as the search box's HTML value attribute. This would also prevent people from being able to assign whatever they want to the value of whoops, which is a security vulnerability.