2013-12-19 264 views
-2

我需要檢查字段patientid的值是否爲空或打印警報。驗證爲空或空輸入字段

不知怎的,下面的代碼是不工作:

<td width="75">Patient ID<font color="red">*</font></td> 
<td width="166"><form:input path="patientid"/></td> 

能否請你幫我嗎?

+0

哪裏是你的代碼? – ram

+1

''?這可能是jsp或模糊的東西?從未見過.. – GitaarLAB

+0

http://mattgemmell.com/what-have-you-tried/ –

回答

0

<form:input path="patientid"/>不是HTML。

這應該讓你開始:

<td width="75">Patient ID<font color="red">*</font></td> 
<td width="166"><input type="text" id="patientid" onchange=" 
    this.value==='' && alert('I am empty'); 
"/></td> 

或者你可以嘗試這樣做:

<td width="75">Patient ID<font color="red">*</font></td> 
<td width="166"><input type="text" id="patientid" onchange=" 
    this.value==='' && (this.value='I cannot be empty'); 
"/></td> 
0

要檢查輸入值爲空只是做到以下幾點:

if(document.getElementById("yourInputsId").value !=""){ 
     //do stuff if its not empty} 
    else{ 
    //do other Stuff 
    }