Skip to main content
deleted 853 characters in body
Source Link
happy
  • 363
  • 4
  • 18

Whenever I am writing a javascript code to check if the input text is taking an empty value, it doesn't work. Please check what is the problem with my code?

Apex Page Code

<apex:page controller="sampleGetSet">

function checkValidation(){ var val1 = document.getElementsById('name').value; if(val1==null || val1==""){ alert('Please enter any value'); return true; } }

<apex:form > <apex:pageBlock > <apex:outputText value="Enter your Name"></apex:outputText> <apex:inputText id="name" value="{!inputtext}" required="true"/> <apex:commandButton value="show" reRender="display" oncomplete="this.form.reset();" onclick="checkValidation()"/> </apex:pageBlock> </apex:form>
<apex:pageblock id="display"> The name entered is:   <apex:outputtext value="{!inputtext}"/> </apex:pageblock>Page Code </apex:page>

Apex Controller Code:Page Code

public class sampleGetSet { public string inputtext {get; set;} }Controller Code

Whenever I am writing a javascript code to check if the input text is taking an empty value, it doesn't work. Please check what is the problem with my code?

Apex Page Code

<apex:page controller="sampleGetSet">

function checkValidation(){ var val1 = document.getElementsById('name').value; if(val1==null || val1==""){ alert('Please enter any value'); return true; } }

<apex:form > <apex:pageBlock > <apex:outputText value="Enter your Name"></apex:outputText> <apex:inputText id="name" value="{!inputtext}" required="true"/> <apex:commandButton value="show" reRender="display" oncomplete="this.form.reset();" onclick="checkValidation()"/> </apex:pageBlock> </apex:form>
<apex:pageblock id="display"> The name entered is:   <apex:outputtext value="{!inputtext}"/> </apex:pageblock> </apex:page>

Apex Controller Code:

public class sampleGetSet { public string inputtext {get; set;} }

Whenever I am writing a javascript code to check if the input text is taking an empty value, it doesn't work. Please check what is the problem with my code?

Page Code Page Code

Controller Code

Source Link
happy
  • 363
  • 4
  • 18

Javascript Code is not working!

Whenever I am writing a javascript code to check if the input text is taking an empty value, it doesn't work. Please check what is the problem with my code?

Apex Page Code

<apex:page controller="sampleGetSet">

function checkValidation(){ var val1 = document.getElementsById('name').value; if(val1==null || val1==""){ alert('Please enter any value'); return true; } }

<apex:form > <apex:pageBlock > <apex:outputText value="Enter your Name"></apex:outputText> <apex:inputText id="name" value="{!inputtext}" required="true"/> <apex:commandButton value="show" reRender="display" oncomplete="this.form.reset();" onclick="checkValidation()"/> </apex:pageBlock> </apex:form>
<apex:pageblock id="display"> The name entered is:   <apex:outputtext value="{!inputtext}"/> </apex:pageblock> </apex:page>

Apex Controller Code:

public class sampleGetSet { public string inputtext {get; set;} }