Suppose I have three kind of HTML coming either of them:
<input name="myName" id="myID" role="textbox" style="width: 98%;" type="text" value="SDFSF"/>
OR
<input name="myName" id="myID" role="textbox" style="width: 98%;" type="text" value='SDFSF'/>
OR
<input name="myName" id="myID" role="textbox" style="width: 98%;" type="text"/>
I don't know which of them coming. I am trying to edit them like this:
<input name="myName" id="myID" role="textbox" style="width: 98%;" type="text" value=''/>
I am using this thing:
html = html.replace(/value="(?:[^\\"]+|\\.)*"/,"value=''");
This is able to replace value="Something" to value=''. How can I extend this for other two? Is there any option for OR in Javascript?
Edit
I don't have the DOM element. So, I have to use it like this.
document.getElementById("myID").value = ""getElementByIdonly works tough if the element is part of the document. If the OP gets the data as HTML string, that won't work. There are, however, other and equally easy ways.