我在标准表单中使用了成功的Livevalidation。当我在JavaScript中使用修改后的表单中的Valdidation时,它将无法正常工作。
<Input type="Ratio" value="1">: Validation for "Submit" not necessary
<Input type="Ratio" value="-1">: Validation necessary
<Input type="Ratio" value="-2">: Validation necessary
然后我选择“值1”(不需要Livevalidation)我无法“提交”表单
<script type="text/javascript">
function changeState(state) {
var id = parseInt(state);
if (id >= 0)
{
$('#new_delivery_address').hide("slow");
$('#packstation').remove();
// Livevalidation
var title = new LiveValidation('title');
var firstName = new LiveValidation('firstName');
var lastName = new LiveValidation('lastName');
var firm = new LiveValidation('firm');
var street = new LiveValidation('street');
var streetnumber = new LiveValidation('streetnumber');
var street2 = new LiveValidation('street2');
var plz = new LiveValidation('plz');
var city = new LiveValidation('city');
var tel = new LiveValidation('tel');
title.destroy(true);
firstName.destroy(true);
lastName.destroy(true);
firm.destroy(true);
street.destroy(true);
streetnumber.destroy(true);
street2.destroy(true);
plz.destroy(true);
city.destroy(true);
tel.destroy(true);
}
if (id == -2)
{
// Code
// Code
// ...
// Livevalidierung
var title = new LiveValidation('title');
var firstName = new LiveValidation('firstName');
var lastName = new LiveValidation('lastName');
var firm = new LiveValidation('firm');
var street = new LiveValidation('street');
var street2 = new LiveValidation('street2');
var plz = new LiveValidation('plz');
var city = new LiveValidation('city');
var tel = new LiveValidation('tel');
firstName.add( Validate.Presence);
lastName.add( Validate.Presence);
street.add(Validate.Presence);
street2.add(Validate.Presence);
plz.add(Validate.Presence);
plz.add(Validate.Numericality);
plz.add(Validate.Length, { minimum: 4, maximum: 5 } );
city.add(Validate.Presence);
streetnumber.destroy(true);
}
if (id == -1)
{
// Code
// Code
// ...
// Livevalidierung
var title = new LiveValidation('title');
var firstName = new LiveValidation('firstName');
var lastName = new LiveValidation('lastName');
var firm = new LiveValidation('firm');
var street = new LiveValidation('street');
var streetnumber = new LiveValidation('streetnumber');
var street2 = new LiveValidation('street2');
var plz = new LiveValidation('plz');
var city = new LiveValidation('city');
var tel = new LiveValidation('tel');
firstName.add( Validate.Presence);
lastName.add( Validate.Presence);
street.add(Validate.Presence);
streetnumber.add(Validate.Presence);
plz.add(Validate.Presence);
plz.add(Validate.Numericality);
plz.add(Validate.Length, { minimum: 4, maximum: 5 } );
city.add(Validate.Presence);
street2.destroy(true);
}
}
function 123 () {
// Code
// Code
// ...
}
答案 0 :(得分:0)
现在我找到了“第二个问题:......不能”提交“表格”的解决方案
我参与了禁用(功能)和启用(功能)
的参数 <script type="text/javascript">
function changeState(state) {
var id = parseInt(state);
if (id >= 0)
{
$('#new_delivery_address').hide("slow");
$('#packstation').remove();
// Livevalidation
var title = new LiveValidation('title');
var firstName = new LiveValidation('firstName');
var lastName = new LiveValidation('lastName');
var firm = new LiveValidation('firm');
var street = new LiveValidation('street');
var streetnumber = new LiveValidation('streetnumber');
var street2 = new LiveValidation('street2');
var plz = new LiveValidation('plz');
var city = new LiveValidation('city');
var tel = new LiveValidation('tel');
title.destroy(true);
firstName.destroy(true);
lastName.destroy(true);
firm.destroy(true);
street.destroy(true);
streetnumber.destroy(true);
street2.destroy(true);
plz.destroy(true);
city.destroy(true);
tel.destroy(true);
title.disable(true);
firstName.disable(true);
lastName.disable(true);
firm.disable(true);
street.disable(true);
streetnumber.disable(true);
street2.disable(true);
plz.disable(true);
city.disable(true);
tel.disable(true);
}
if (id == -2)
{
// Code
// Code
// ...
// Livevalidierung
var title = new LiveValidation('title');
var firstName = new LiveValidation('firstName');
var lastName = new LiveValidation('lastName');
var firm = new LiveValidation('firm');
var street = new LiveValidation('street');
var street2 = new LiveValidation('street2');
var plz = new LiveValidation('plz');
var city = new LiveValidation('city');
var tel = new LiveValidation('tel');
title.enable(true);
firstName.enable(true);
lastName.enable(true);
firm.enable(true);
street.enable(true);
street2.enable(true);
plz.enable(true);
city.enable(true);
tel.enable(true);
lastName.add(Validate.Presence);
street.add(Validate.Presence);
street2.add(Validate.Presence);
plz.add(Validate.Presence);
plz.add(Validate.Numericality);
plz.add(Validate.Length, { minimum: 4, maximum: 5 } );
city.add(Validate.Presence);
streetnumber.destroy(true);
streetnumber.remove(true);
}
if (id == -1)
{
// Code
// Code
// ...
// Livevalidierung
var title = new LiveValidation('title');
var firstName = new LiveValidation('firstName');
var lastName = new LiveValidation('lastName');
var firm = new LiveValidation('firm');
var street = new LiveValidation('street');
var streetnumber = new LiveValidation('streetnumber');
var street2 = new LiveValidation('street2');
var plz = new LiveValidation('plz');
var city = new LiveValidation('city');
var tel = new LiveValidation('tel');
title.enable(true);
firstName.enable(true);
lastName.enable(true);
firm.enable(true);
street.enable(true);
streetnumber.enable(true);
street2.enable(true);
plz.enable(true);
city.enable(true);
tel.enable(true);
lastName.add(Validate.Presence);
street.add(Validate.Presence);
streetnumber.add(Validate.Presence);
plz.add(Validate.Presence);
plz.add(Validate.Numericality);
plz.add(Validate.Length, { minimum: 4, maximum: 5 } );
city.add(Validate.Presence);
street2.destroy(true);
street2.remove(true);
}
}
function 123 () {
// Code
// Code
// ...
}