---
title: "为空判断"
author: "kenrome"
date: "2010-08-30T14:54:28Z"
tags: []
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2010-08-30T14:54:28Z"
id: 750799
url: "https://inruby.iteye.com/blog/750799"
---

服务器端的为空判断：ruby


```java
class String
	def blank?
		self.nil? || self.strip.empty?
	end
end
```


网页前端的为空判断：js

```java

function Check()
	{
		sel = document.yform.manual_action_title_select.value.replace(/\s/gi,"");
		input = document.yform.manual_action_title_input.value.replace(/\s/gi,"");
		if( sel == "" && input == "" ) {alert("value required!");return false;}
		
		return true;
	}

```