PHP转换中需要的HTML5事件自定义验证
我需要一些关于PHP版本的required属性的帮助。 必填字段工作正常,但问题在于oninvalid元素以HTML格式显示自定义文本 这是HTML版本:PHP转换中需要的HTML5事件自定义验证,php,wordpress,html,woocommerce,Php,Wordpress,Html,Woocommerce,我需要一些关于PHP版本的required属性的帮助。 必填字段工作正常,但问题在于oninvalid元素以HTML格式显示自定义文本 这是HTML版本: <select required="" oninvalid="this.setCustomValidity('Custom TXT!')"> $options = $args['options']; $product = $args['product'];
<select required="" oninvalid="this.setCustomValidity('Custom TXT!')">
$options = $args['options'];
$product = $args['product'];
$attribute = $args['attribute'];
$name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title( $attribute );
$id = $args['id'] ? $args['id'] : sanitize_title( $attribute );
$class = $args['class'];
$show_option_none = $args['show_option_none'] ? true : false;
$show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __( 'Choose an option', 'woocommerce' ); // We'll do our best to hide the placeholder, but we'll need to show something when resetting options.
if ( empty( $options ) && ! empty( $product ) && ! empty( $attribute ) ) {
$attributes = $product->get_variation_attributes();
$options = $attributes[ $attribute ];
}
$html = '<select required="" oninvalid="this.setCustomValidity('Custom TXT!')" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ) . '" name="' . esc_attr( $name ) . '" data-attribute_name="attribute_' . esc_attr( sanitize_title( $attribute ) ) . '"' . '" data-show_option_none="' . ( $show_option_none ? 'yes' : 'no' ) . '">';
$html .= '<option value="">' . esc_html( $show_option_none_text ) . '</option>';
这是我的PHP版本的选择下拉框:
<select required="" oninvalid="this.setCustomValidity('Custom TXT!')">
$options = $args['options'];
$product = $args['product'];
$attribute = $args['attribute'];
$name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title( $attribute );
$id = $args['id'] ? $args['id'] : sanitize_title( $attribute );
$class = $args['class'];
$show_option_none = $args['show_option_none'] ? true : false;
$show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __( 'Choose an option', 'woocommerce' ); // We'll do our best to hide the placeholder, but we'll need to show something when resetting options.
if ( empty( $options ) && ! empty( $product ) && ! empty( $attribute ) ) {
$attributes = $product->get_variation_attributes();
$options = $attributes[ $attribute ];
}
$html = '<select required="" oninvalid="this.setCustomValidity('Custom TXT!')" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ) . '" name="' . esc_attr( $name ) . '" data-attribute_name="attribute_' . esc_attr( sanitize_title( $attribute ) ) . '"' . '" data-show_option_none="' . ( $show_option_none ? 'yes' : 'no' ) . '">';
$html .= '<option value="">' . esc_html( $show_option_none_text ) . '</option>';
$options=$args['options'];
$product=$args['product'];
$attribute=$args['attribute'];
$name=$args['name']$args['name']:'attribute_'。清理标题($attribute);
$id=$args['id']$args['id']:清除标题($attribute);
$class=$args['class'];
$show\u option\u none=$args['show\u option\u none']?真:假;
$show\u option\u none\u text=$args['show\u option\u none']$args['show_option_none']:uuu('Choose an option','woocommerce');//我们将尽力隐藏占位符,但在重置选项时需要显示一些内容。
if(空($options)&!空($product)&&!空($attribute)){
$attributes=$product->get_variation_attributes();
$options=$attributes[$attribute];
}
$html='嗯。。。这是我使用普通IDE而不是np++的教训
oninvalid="this.setCustomValidity(\'Custom TXT!\')"
已关闭。可能与否重复。。。我需要PHP代码中的这个元素…好吧,你必须把它转换成你的PHPstring@LGSon可能需要帮忙吗?:)如果您知道PHP语法,这应该很简单。。我不是,我是.NET开发者哈哈!我确信那些人一定是逃出来的。很高兴你终于明白了。:)