i need a regular expression that checks if the multiline textbox has been left emtpy. It should match on anything except whitespace. Im using ASP.NET.
I know i could use a Required Field Validator, but this will not allow me to run a custom javascript script on failed validation.
Thanks
i need a regular expression that checks if the multiline textbox has been left emtpy. It should match on anything except whitespace. Im using ASP.NET.
I know i could use a Required Field Validator, but this will not allow me to run a custom javascript script on failed validation.
Thanks
Share Improve this question asked Oct 30, 2011 at 16:47 TheGateKeeperTheGateKeeper 4,53023 gold badges68 silver badges105 bronze badges4 Answers
Reset to default 2Use the \S
predefined set. it will match anything that is not whitespace.
var text = textBox.value;
text = text.replace(/^\s*/,'').replace(/\s*$/,''); // trimming
if(text){
// run your code here
}
Maybe you can use a CustomValidator
, as RegularExpressionValidator
doesn't support empty strings. But you must define ValidateEmptyText=true
try this:
^[\s\t\r\n]*\S+
test => http://jsfiddle/KFCHM/
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745036710a4607563.html
评论列表(0条)