duan205571 2013-03-31 18:07
浏览 43

在emptyy中将空输入字段验证为正确的值

<td><input type="text" name="remove" value="Remove this text"></td>

How can i use smarty validation directly in my template file. The correct value for the textbox is empty.

I'm trying to avoid using Javascript, and I know I can do it either in the template file or the PHP. I haven't seen any real good examples of this.

I'm confused, and I would appreciate some help.

  • 写回答

1条回答 默认 最新

  • duanjianao0592 2013-03-31 23:19
    关注

    You can not validate anything using smarty. Smarty is for templating, that means: Smarty is there for generating output solely.

    If you want to check if that element is empty, you have to rely on javascript or your server-sided language, e.g. PHP.

    The only way to to anything roughly in your direction with smarty would be like this:

    <td>
        {if $element_not_empty}<div class="error">Please remove the text!</div>{/if}
        <input type="text" name="remove" value="Remove this text">
    </td>
    

    But, of course, the variable $element_not_empty would be generated by PHP so there you are at server-sided validation again ;)

    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改