GVKun编程网logo

“必需”属性在 PHP HTML 中不起作用(html必填属性)

1

在这篇文章中,我们将为您详细介绍“必需”属性在PHPHTML中不起作用的内容,并且讨论关于html必填属性的相关问题。此外,我们还会涉及一些关于-webkit-text-security:光盘;css

在这篇文章中,我们将为您详细介绍“必需”属性在 PHP HTML 中不起作用的内容,并且讨论关于html必填属性的相关问题。此外,我们还会涉及一些关于-webkit-text-security:光盘; css 属性在 Firefox 浏览器中不起作用、@media 打印 { 分页前; page-break-after} 属性在 IONIC角度中不起作用 在 .ts 文件中在 css 中、@Value 属性在 spring 组件中返回 null、AllowUserToAddRow 属性在 .NET/C# (DataGridView) 中不起作用的知识,以帮助您更全面地了解这个主题。

本文目录一览:

“必需”属性在 PHP HTML 中不起作用(html必填属性)

“必需”属性在 PHP HTML 中不起作用(html必填属性)

如何解决“必需”属性在 PHP HTML 中不起作用

我试图为空字段添加验证。如果字段为空,则不会提交表单。但是我的“必需”属性不起作用。

  1. Birthdate:
  2. <select name="month" required>
  3. <option value="0" required>Select Month</option>
  4. <?PHP
  5. for( $m = 1; $m <= 12; $m++ )
  6. {
  7. $num = str_pad( $m,2,STR_PAD_LEFT );
  8. $month = date( ''F'',mktime( 0,$m + 1,0 ) );?>
  9. <option value="<?PHP echo $num;?>"><?PHP echo $month; ?></option>
  10. <?PHP
  11. }
  12. ?>
  13. </select>
  14. </select>

解决方法

<option> 不需要''required'',只需在<select> 中就足够了。如果您想获得第一个作为默认值,请使用“selected”而不是“required”。

,

选项标签没有必需的属性。

  1. <select name="month" required>
  2. <option value="0">Select Month</option>
  3. <?php
  4. for( $m = 1; $m <= 12; $m++ )
  5. {
  6. $num = str_pad( $m,2,STR_PAD_LEFT );
  7. $month = date( ''F'',mktime( 0,$m + 1,0 ) );?>
  8. <option value="<?php echo $num;?>"><?php echo $month; ?></option>
  9. <?php
  10. }
  11. ?>
  12. </select>

https://developer.mozilla.org/es/docs/Web/HTML/Element/option

,

您可以在第一个选项中取消设置值。示例:

  1. <select name="month" required>
  2. <option value="" required>Select Month</option>
  3. <option value="1">January</option>
  4. <option value="2">February</option>
  5. <option value="3">March</option>
  6. <option value="4">...</option>
  7. </select>

-webkit-text-security:光盘; css 属性在 Firefox 浏览器中不起作用

-webkit-text-security:光盘; css 属性在 Firefox 浏览器中不起作用

如何解决-webkit-text-security:光盘; css 属性在 Firefox 浏览器中不起作用

-webkit-text-security:光盘; css 属性在 Firefox 浏览器中不起作用

在 mozilla 中是否有相同的替代方案。请帮忙

解决方法

更新代码:

@font-face{
  font-family: text-security-disc;
  src: url("https://raw.githubusercontent.com/noppa/text-security/master/dist/text-security-disc.woff");
}

input {
  font-family: text-security-disc;
  -webkit-text-security: disc;
}
<input type="text">



注意:- 如果您不想将 password 作为输入类型, 我能想到的唯一方法是使用“光盘”之类的字体进行输入。我不建议这样做,因为任何人都可以将密码复制粘贴到文本编辑器并查看它。如果你想继续,这里是 github 存储库的 link。 (我没有测试过,所以我不确定)

@media 打印 { 分页前; page-break-after} 属性在 IONIC角度中不起作用 在 .ts 文件中在 css 中

@media 打印 { 分页前; page-break-after} 属性在 IONIC角度中不起作用 在 .ts 文件中在 css 中

如何解决@media 打印 { 分页前; page-break-after} 属性在 IONIC角度中不起作用 在 .ts 文件中在 css 中

假设它是一个示例代码?

  1. <div id="print-div">
  2. <p>Lorem ipsum dolor sit amet page 1.</p>
  3. <ion-label>page break here</ion-label>
  4. <p>Lorem ipsum dolor sit amet page 2.</p>
  5. </div>

我想打印这部分,第一段在第一页,第二段在下一页。

在 .ts 文件中

  1. printThis(){
  2. let backup = document.body.innerHTML;
  3. let divcontent = document.getElementById(''print-div'').innerHTML;
  4. document.body.innerHTML = divcontent;
  5. window.print();
  6. document.body.innerHTML = backup;
  7. }

在 css 中

  1. @media print {
  2. ion-label{
  3. page-break-before: always !important;
  4. }
  5. }

但这不会在打印时破坏页面。 所有数据都打印在一页中,如果内容大于一页,它仍然打印任何一页的数据。

我试过

  1. page-break-before: always;
  1. page-break-after: always;
  1. break-after: always;

但是什么都没发生。

如果有人帮助我了解如何在 ionic 中使用 page-break 属性。 我会很感激的。

解决方法

问题:

ion-content 组件有一个绝对定位的内部 div。由于 ionic 使用带有 shadow-root 的 web-components 并且定位未公开为 css 变量,因此无法使用 css 样式表设置此样式属性。但是:分页符不适用于绝对定位的元素 w3schools

解决方案:

使用JS操作shadow-root并将定位设置为relative。 github: ionic-print-test

我遇到了同样的问题,并通过使用事件侦听器 onbeforeprintonafterprint 解决了它。这是一个带有 angular 的 ionic 示例,但逻辑可以很容易地重构为 react 或 vue。 ionic-print-test:issue

print.service.ts

  1. import { DOCUMENT } from ''@angular/common'';
  2. import { Inject,Injectable } from ''@angular/core'';
  3. @Injectable({
  4. providedIn: ''root'',})
  5. export class PrintService {
  6. constructor(@Inject(DOCUMENT) private document: HTMLDocument) {}
  7. init() {
  8. window.onbeforeprint = () => this.setPrintStyles(true);
  9. window.onafterprint = () => this.setPrintStyles(false);
  10. }
  11. private setPrintStyles(add: boolean) {
  12. this.document.querySelectorAll(''ion-content'').forEach((element) => {
  13. const scroll = element.shadowRoot.querySelector(''.inner-scroll'') as HTMLElement;
  14. if (add) {
  15. scroll.style.position = ''relative'';
  16. } else {
  17. scroll.style.removeProperty(''position'');
  18. }
  19. });
  20. }
  21. }
,

对于我添加这项工作。离子 4,角 8

  1. @media print {
  2. body {
  3. position: relative !important;
  4. }
  5. }

https://medium.com/@Idan_Co/angular-print-service-290651c721f9

@Value 属性在 spring 组件中返回 null

@Value 属性在 spring 组件中返回 null

如何解决@Value 属性在 spring 组件中返回 null

我在 spring boot 中创建了一个验证器组件,我在 application.properties 中保留了一个正则表达式。我已经使用 @Value 注释来获取组件中正则表达式的值,并且我正在任何方法或构造函数之外编译模式,这给了我空指针异常,因为当时正则表达式没有获得它的值。但是当我将模式移动到某种方法时,它工作正常。这是为什么? 为什么即使使用@Component 创建对象,@Value 也不起作用

看下面的代码:

返回 NullPointerException 的代码:

  1. @Component
  2. public class ValidString implements ConstraintValidator<ValidString,String> {
  3. @Value("${user.input.regex}")
  4. private String USER_INPUT_REGEX;
  5. private Pattern USER_INPUT_PATTERN = Pattern.compile(USER_INPUT_REGEX);
  6. @Override
  7. public boolean validate(String userInput,ConstraintValidatorContext constraintValidatorContext) {
  8. return USER_INPUT_PATTERN.matcher(userInput).find();
  9. }
  10. }

代码工作正常:

  1. @Component
  2. public class ValidString implements ConstraintValidator<ValidString,String> {
  3. @Value("${user.input.regex}")
  4. private String USER_INPUT_REGEX;
  5. private Pattern USER_INPUT_PATTERN;
  6. @Override
  7. public boolean validate(String userInput,ConstraintValidatorContext constraintValidatorContext) {
  8. USER_INPUT_PATTERN = Pattern.compile(USER_INPUT_REGEX);
  9. return USER_INPUT_PATTERN.matcher(userInput).find();
  10. }
  11. }

此外,如果您能解释为什么第一个不起作用而第二个起作用,那就太好了。

application.properties

  1. user.input.regex = ^[a-zA-Z0-9/\\\\-_ \\\\s+]*$

解决方法

字段初始值设定项(有问题的第一个示例)在 类构造函数执行期间执行。 @Value 由 Spring 注入 构造函数返回后,使用反射。这意味着您不能拥有使用 @Value 注入值的初始化程序。

这个问题可以通过构造函数或setter注入来解决:

  1. // Inject using constructor
  2. @Component
  3. public class ValidString implements ConstraintValidator<ValidString,String> {
  4. private Pattern USER_INPUT_PATTERN;
  5. @Autowired
  6. public ValidString(@Value("${user.input.regex}") String regex) {
  7. this.USER_INPUT_PATTERN = Pattern.compile(regex);
  8. }
  1. // Inject using setter method
  2. @Component
  3. public class ValidString implements ConstraintValidator<ValidString,String> {
  4. private Pattern USER_INPUT_PATTERN;
  5. @Autowired
  6. private void setUserInputRegex(@Value("${user.input.regex}") String regex) {
  7. this.USER_INPUT_PATTERN = Pattern.compile(regex);
  8. }
,

模式 USER_INPUT_PATTERN 在 spring 过程之前。 类 ValidString 对象初始顺序为:->process field initial->constructor -> inject field 所以,当你使用1个代码时,它必须是空点,因为字段没有注入

AllowUserToAddRow 属性在 .NET/C# (DataGridView) 中不起作用

AllowUserToAddRow 属性在 .NET/C# (DataGridView) 中不起作用

如何解决AllowUserToAddRow 属性在 .NET/C# (DataGridView) 中不起作用

我有一个链接到 BindingSource 的 DataGridView

  • AllowUserToAddRow 属性为 DGV 设置为 true
  • AllowNew 将绑定源的属性设置为 true
  • 与 datagridview 的 ReadOnly 属性没有冲突

我尝试为绑定源中引用的类型添加一个参数较少的公共构造函数,但也不起作用。

PS:我使用 ToBindingList() 而不是 ToList() 方法来影响数据源。

在设计器中,DGV 显示了带星号的空行(展示了添加行的能力),但是一旦运行项目它就消失了,所以我无法在 DGV 中添加任何行。

有任何线索吗?

我们今天的关于“必需”属性在 PHP HTML 中不起作用html必填属性的分享已经告一段落,感谢您的关注,如果您想了解更多关于-webkit-text-security:光盘; css 属性在 Firefox 浏览器中不起作用、@media 打印 { 分页前; page-break-after} 属性在 IONIC角度中不起作用 在 .ts 文件中在 css 中、@Value 属性在 spring 组件中返回 null、AllowUserToAddRow 属性在 .NET/C# (DataGridView) 中不起作用的相关信息,请在本站查询。

本文标签:

上一篇在 PHP 中的函数内使用全局 $foo 与使用 $GLOBALS['foo'](php提供的三种在函数内使用全局变量的方式)

下一篇PHP 安全图像上传控制?(php 安全图像上传控制在哪)