Во-первых, имя всех переключателей должно быть одинаковым. Таким образом, он может выбрать по одному. второй div, который вы отображаете, одновременно скрывает другой div.
function show1() {
document.getElementById('div1').style.display = 'none';
document.getElementById('div2').style.display = 'none';
}
function show2() {
document.getElementById('div2').style.display = 'none';
document.getElementById('div1').style.display = 'block';
}
function show3() {
document.getElementById('div1').style.display = 'none';
document.getElementById('div2').style.display = 'block';
}
body {
font-family: arial;
}
.hide {
display: none;
}
p {
font-weight: bold;
}
<p>Leave</p>
<input type="radio" name="tab" value="igotnone" onclick="show1();" /> Full Day
<input type="radio" name="tab" value="igottwo" onclick="show2();" /> From
<input type="radio" name="tab" value="igottwo" onclick="show3();" /> To
<div id="div1" class="hide">
<hr>
<p>From Which Half Session You Are Not Available???</p>
<input type="radio" value="Yes" name="one"> First Session
<input type="radio" value="Yes" name="one"> Second Session
</div>
<div id="div2" class="hide">
<hr>
<p>To Which Half Session You Are Not Available???</p>
<input type="radio" value="Yes" name="two"> First Session
<input type="radio" value="Yes" name="two"> Second Session
</div>
Событие TextChanged
в будущем можно найти все события на библиотеке MSDN, вот ссылка класса TextBox:
http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox (По сравнению с 80) .aspx
При использовании привязки данных перейдите к Свойствам текстового поля. Откройте (DataBindings) наверху, нажмите на свойство (Advanced), три точки появятся (...) Нажимают на них. Усовершенствованный экран привязки данных появляется. Для каждого свойства TextBox, который связывается в Вашем случае Text
, можно установить, когда привязка данных и таким образом проверка, должны "ударить" использование поля комбинированного списка Data Source Update mode
. Если Вы устанавливаете его на OnPropertyChanged
, это переоценит, поскольку Вы вводите (значение по умолчанию OnValidation
который только обновляет, поскольку Вы снабжаете вкладками).
Как Ваши данные будут допустимы, если они не будут закончены? т.е. пользователь вводит число, и Вы пытаетесь проверить его как дату?
Когда привязка Вашего текстового поля к bindingSource переходит к Усовершенствованному и избранному типу проверки
"На Измененном Свойстве". Это распространит Ваши данные к Вашему объекту на каждом нажатии клавиши. Вот снимок экрана
Необходимо проверять события KeyPress или KeyDown и не только событие TextChanged.
Вот Пример C# непосредственно из документации MSDN:
// Boolean flag used to determine when a character other than a number is entered.
private bool nonNumberEntered = false;
// Handle the KeyDown event to determine the type of character entered into the control.
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
// Initialize the flag to false.
nonNumberEntered = false;
// Determine whether the keystroke is a number from the top of the keyboard.
if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9)
{
// Determine whether the keystroke is a number from the keypad.
if (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9)
{
// Determine whether the keystroke is a backspace.
if(e.KeyCode != Keys.Back)
{
// A non-numerical keystroke was pressed.
// Set the flag to true and evaluate in KeyPress event.
nonNumberEntered = true;
}
}
}
//If shift key was pressed, it's not a number.
if (Control.ModifierKeys == Keys.Shift) {
nonNumberEntered = true;
}
}
// This event occurs after the KeyDown event and can be used to prevent
// characters from entering the control.
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
// Check for the flag being set in the KeyDown event.
if (nonNumberEntered == true)
{
// Stop the character from being entered into the control since it is non-numerical.
e.Handled = true;
}
}